Stamp change while saving changes to the working directory in Git

Is there a git stash command that pauses your changes but also saves them in the working directory? So basically a git stash; git stash apply git stash; git stash apply in one step?

+61
git git-stash
Jul 24 '13 at 19:39
source share
4 answers

For what it's worth, another way to do this is to make the changes you want to save, and then hide everything using --keep-index :

 $ git add modified-file.txt $ git stash save --keep-index 

Everything will be saved in the above commands, including modified-file.txt , but it will also leave this file in the working directory.

From the official Linux Git kernel documentation for git stash :

If the --keep-index option is used, all changes already added to the index remain intact.

+58
Jul 25 '13 at 3:31 on
source share

git stash and then git stash apply ( git stash && git stash apply ) will hide the files and apply the tab immediately. So in the end you will have your changes in the cache and in the working director. You can create an alias if you want it in one part. Just put something like this ~/.gitconfig :

 [alias] sta = "!git stash && git stash apply" 
+25
Jul 24 '13 at 20:08
source share

A slight amplification of the answer, which in practical terms can be used.

 $ git add modified-file.txt (OR $ git add . ---- for all modified file) $ git stash save --keep-index "Your Comment" 
+3
Jun 01 '16 at 9:43
source share

There the trick can help you, not hide, but FWIW:

 git add -A git commit -m "this is what called stashing" (create new stash commit) git tag stash (mark the commit with 'stash' tag) git reset HEAD~ (Now go back to where you've left with your working dir intact) 

So, now you have a tag attached with a commit, in any case it is impossible to make git stash pop , but you can do things like creating patches or reloading files, etc. from there, your dir working files also remain untouched by the way.

+2
Apr 22 '15 at 0:42
source share



All Articles