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
3856
votes
13 answers

Move existing, uncommitted work to a new branch in Git

I started some work on a new feature and after coding for a bit, I decided this feature should be on its own branch. How do I move the existing uncommitted changes to a new branch and reset my current one? I want to reset my current branch while…
Dane O'Connor
  • 75,180
  • 37
  • 119
  • 173
3696
votes
32 answers

How do I stash only one file out of multiple files that have changed?

How do I stash only one of the multiple changed files on my branch?
Rachel
  • 100,387
  • 116
  • 269
  • 365
2607
votes
1 answer

See what's in a stash without applying it

How do I see what is inside a stash without actually applying it?
Chris Abrams
  • 39,732
  • 19
  • 51
  • 57
2420
votes
24 answers

How do I recover a dropped stash in Git?

I frequently use git stash and git stash pop to save and restore changes in my working tree. Yesterday, I had some changes in my working tree that I had stashed and popped, and then I made more changes to my working tree. I'd like to go back and…
Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
2316
votes
14 answers

How can I git stash a specific file?

How can I stash a specific file leaving the others currently modified out of the stash I am about to save? For example, if git status gives me this: younker % gst # On branch master # Your branch is ahead of 'origin/master' by 1 commit. # #…
ynkr
  • 25,946
  • 4
  • 32
  • 30
2316
votes
28 answers

How do I name and retrieve a Git stash by name?

How do I save/apply a stash with a name? I don't want to have to look up its index number in git stash list. I tried git stash save "my_stash_name", but that only changes the stash description, and the corresponding git apply "my_stash_name" doesn't…
Suan
  • 34,563
  • 13
  • 47
  • 61
2271
votes
20 answers

How do you stash an untracked file?

I have changes to a file, plus a new file, and would like to use git stash to put them away while I switch to another task. But git stash by itself stashes only the changes to the existing file; the new file remains in my working tree, cluttering…
skiphoppy
  • 97,646
  • 72
  • 174
  • 218
2060
votes
12 answers

How can I delete all of my Git stashes at once?

How can I delete all of my Git stashes at once? Specifically I mean, with typing in one command.
Rebekah Waterbury
  • 22,236
  • 5
  • 23
  • 28
1811
votes
15 answers

Git diff against a stash

How can I see the changes un-stashing will make to the current working tree? I would like to know what changes will be made before applying them!
Tegra Detra
  • 24,551
  • 17
  • 53
  • 78
1527
votes
9 answers

Difference between git stash pop and git stash apply

I've been using git stash pop for quite some time. I recently found out about the git stash apply command. When I tried it out, it seemed to work the same as git stash pop. What is the difference between git stash pop and git stash apply?
Sandeep Raju Prabhakar
  • 18,652
  • 8
  • 35
  • 44
1217
votes
6 answers

Git: Create a branch from unstaged/uncommitted changes on master

Context: I'm working on master adding a simple feature. After a few minutes I realize it was not so simple and it should have been better to work into a new branch. This always happens to me and I have no idea how to switch to another branch and…
knoopx
  • 17,089
  • 7
  • 36
  • 41
1097
votes
10 answers

How would I extract a single file (or changes to a file) from a git stash?

Is it possible to extract a single file or diff of a file from a git stash without popping the stash changeset off?
Danny
  • 13,194
  • 4
  • 31
  • 36
988
votes
8 answers

How to recover stashed uncommitted changes

I had some uncommitted changes in my development branch and I stashed them using git stash, but there were some changes which were very important among those stashed ones. Is there any way to get back those changes? Also, I have made some changes on…
Aswathy P Krishnan
  • 11,728
  • 7
  • 27
  • 45
939
votes
13 answers

How to delete a stash created with git stash create?

Git stash seems to do a lot of what I want, except that it is a little hard to script, as the if you have no changes, then git stash; git stash pop will do something different than if you do have changes in your repository. It appears that git stash…
Paul Wagland
  • 27,756
  • 10
  • 52
  • 74
902
votes
6 answers

Undo git stash pop that results in merge conflict

I began making changes to my codebase, not realizing I was on an old topic branch. To transfer them, I wanted to stash them and then apply them to a new branch off of master. I used git stash pop to transfer work-in-progress changes to this new…
acjay
  • 34,571
  • 6
  • 57
  • 100
1
2 3
44 45