Questions tagged [git-stash]

Allows to move pending changes in a working git directory away and restore them later, i.e. put them on a stash. You can have multiple stashes and it can also be used to move pending changes to another branch.

git stash allows you to stash changes in working directory, and then restoring them later, possibly on another branch.

Stashing changes is usually necessary when you need a clean working copy, e.g. before using or .

Popular questions

See also

References

$ git stash --help
675 questions
18
votes
2 answers

Is there a way to output the previous git branch name?

This answer tells how to checkout to the previous branch, and helpfully explains @{-1}: https://stackoverflow.com/a/7207542/3150057 The previous branch is important if I stashed some code before changing branch, and am now thinking about working on…
Henry Blyth
  • 1,700
  • 1
  • 15
  • 23
18
votes
3 answers

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

IN SHORT Is there a possibility to create a stash (using git stash create) without the need to configure user.email and user.name? Something similar to the git commit --author option? SOME CONTEXT: I have several build machines on which I have a…
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
18
votes
3 answers

Is there a graphical way to git stash/unstash individual files?

I am looking for a GUI for stashing and stash popping files in git, with the ability to do so for individual modified files. I know there is a command line way to do so, seen here, but I am looking for a graphical way. I don't care so much about…
Chance
  • 2,653
  • 2
  • 26
  • 33
18
votes
2 answers

GIT: Do I need to commit my branch before checking out another branch, what about stashing?

I'm new to Git and a bit confused. I have a Master branch and have created a second feature branch. If I make changes in my feature branch and then switch to Master, will my changes be lost if I don't commit? Where does stash come into play, is…
Tom DeMille
  • 3,207
  • 3
  • 23
  • 30
16
votes
2 answers

Undo git stash pop on dirty working tree

This seems very foolish mistake, I just did a git stash pop on a dirty working tree. I do not know any way of keeping the desired changes and undoing the stash pop. Does one exist? Or such a mistake is unforgivable?
0xc0de
  • 8,028
  • 5
  • 49
  • 75
16
votes
3 answers

How to ignore added hunks in `git stash -p`

Imagine this scenario: # edit two files git add -p // add hunks from one file Now when you run git stash -p, it will again ask you whether you want to stash the hunks that you just selected via git add -p. Is there some way to configure git to…
milianw
  • 5,164
  • 2
  • 37
  • 41
16
votes
5 answers

Can I use git pull --rebase instead of "git stash git pull git stash pop"?

What is the difference between git pull --rebase and git stash git pull git stash pop
Raja
  • 161
  • 1
  • 1
  • 5
16
votes
2 answers

What are those 'WIP' and 'index' commits that appear after stashing?

When I run git lg on my local development branch, the latest commit is shown as below: * 7d21213 - (1 hours ago) update business rules - developer1 (HEAD, origin/develop, origin/HEAD, develop) However, if I stash local changes by running git stash…
clockworks
  • 3,755
  • 5
  • 37
  • 46
15
votes
2 answers

Is there a maximum number of git stashes?

Is there a maximum number of git stashes, or can you have as many as you like? I'm aware that git stash list doesn't list as many results as git stash list --date=local But does Linus Torvalds think that anyone with more than x stashes is an idiot…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
15
votes
2 answers

How do I resolve git merge conflicts on a submodule from `git stash pop`

I have a git repository with a submodule. I need to pop changes I've previously stashed. However, this is causing a merge conflict on the submodule reference. I want to keep my changes from the stash, except for the submodule. For most code files, I…
Mashmagar
  • 2,556
  • 2
  • 29
  • 38
15
votes
2 answers

How to recover from "git stash save --all"?

I wanted to stash untracked files, but I keep passing the wrong option. To me this sounds right: git stash save [-a|--all] but this in fact stashes ignored files as well. The correct one is: git stash save [-u|--include-untracked] When I run git…
silvenon
  • 2,068
  • 15
  • 29
15
votes
3 answers

How to emulate 'git stash' in fossil, bzr?

Is it possible to emulate the behavior of 'git stash' when using fossil/bzr? Basically I'm interested in handling the following workflow: at some point the source code tree has state X, it is commited I proceed to writing new code, I write it for a…
JS_is_bad
  • 369
  • 4
  • 8
14
votes
1 answer

git status: what is UU and why should add/rm fix it?

Here is the current state of this feature branch. Recent Steps: Remote development branch diverged Fetched remote development branch Stashed local feature branch's diverged changes that I want to keep Rebased feature branch from local development…
Dylan Valade
  • 5,565
  • 6
  • 42
  • 56
14
votes
2 answers

git stash restoring index state of deleted and renamed files

When stashing staged deleted or renamed files, and then unstashing them, they are restored in both their deleted and non deleted state. In the following example state: $ git status s A file0 D file1 R file2 -> file3 ?? file4 running git stash…
Elia Grady
  • 468
  • 3
  • 16
14
votes
3 answers

Is there a way to re-order Git stashes?

In Git one can make multiple stashes: git stash save "quick temp stash" git stash save "another quick temp stash" git stash save "This is important but I need to put it on the back burner" git stash save "This is almost certainly garbage, but just…
machineghost
  • 33,529
  • 30
  • 159
  • 234