Git create stash without having to configure user.email and user.name (git stash --author?)

IN SHORT

Is it possible to create stash (using git stash create ) without having to configure user.email and user.name ? Something similar to the git commit --author ?

SOME CONTEXT:

I have several build machines on which I have a build user. Each of them has access to the central git repositories. However, I did not configure user.email and user.name for each of these users; since they never need to commit.

In one of my scripts, I use

 git stash create 

(which allows me to use the git --format-gtz archive ... I will show you the details, see my question)

However, this command does not work:

 *** Please tell me who you are. Run git config --global user.email " you@example.com " git config --global user.name "Your Name" to set your account default identity. Omit --global to set the identity only in this repository. fatal: empty ident name (for < macq@chmalap.macqel >) not allowed Cannot save the current index state 

PS: I have git 1.8.4

+14
source share
3 answers

With the git -c flag configuration options, you can pass it on the command line:

 git -c user.name=test -c user.email=test@test.com stash create 
+16
source

With Git 2.21 (Q1 2019, 2+ years later), you don’t have to configure user.email and user.name ( git stash --author ? ).

A properly configured username / email address is required in user.useConfigOnly to create commits; now the git stash command (even though it creates commit objects to represent stash entries) is freed from the requirement .

See commit 3bc2111 (November 18, 2018) from Slavitsa Dzhukich ('') .
Assistant: Junio ​​S. Hamano ( gitster ) .
(Merged by Junio ​​C Hamano - [TG46] - in commit 1328d29 , 04 Jan 2019)

stash : allow no user id

The git stash command insists on having the user's identity usable to the same extent as the git commit-tree and git commit commands, because it uses the same code that creates the commit objects as these teams.

This is not necessary.

Before creating commit objects, we check to see if we will issue fake credentials to satisfy the mechanism that creates commits.
Add a test to the document so that stash runs correctly with or without a valid identifier.

This is not much to improve usability, because users who run git stash will ultimately want to record their changes, which are temporarily stored in stash in a more permanent history, by commit, and they must do a git config user.{name,email} "in any case, therefore, perhaps this change only delays the step necessary for working in the repository.

+4
source

If you just want to remove any local changes from the working copy and you are sure that there is nothing to save for later , you can execute an alarmingly dangerous command:

 git checkout . 

This question may be more useful than just git stash create (the problem is with any use of git stash ). The question I answered probably duplicates this question.

+1
source

All Articles