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
605 questions
3387
votes
9 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
  • 67,996
  • 36
  • 114
  • 164
3327
votes
33 answers

Stash only one file out of multiple files that have changed with Git?

How can I stash only one of multiple changed files on my branch?
Rachel
  • 91,207
  • 112
  • 255
  • 361
2084
votes
1 answer

See what's in a stash without applying it

I see here you can apply/unapply a stash and even create a new branch off of a stash. Is it possible to simply see what is inside the stash without actually applying it?
Chris Abrams
  • 32,712
  • 19
  • 49
  • 56
1963
votes
21 answers

How to 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
  • 828,234
  • 170
  • 1,097
  • 1,237
1749
votes
4 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
  • 20,186
  • 4
  • 30
  • 30
1697
votes
16 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
  • 83,104
  • 64
  • 169
  • 214
1686
votes
22 answers

How to name and retrieve a stash by name in git?

I was always under the impression that you could give a stash a name by doing git stash save stashname, which you could later on apply by doing git stash apply stashname. But it seems that in this case all that happens is that stashname will be used…
Suan
  • 27,428
  • 12
  • 44
  • 60
1506
votes
14 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!
Heavy Gray
  • 21,077
  • 14
  • 49
  • 72
1206
votes
8 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
  • 14,834
  • 7
  • 33
  • 42
1083
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
  • 15,557
  • 7
  • 34
  • 41
883
votes
9 answers

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

I'd like to know if it is possible to extract a single file or diff of a file from a git stash without popping the stash changeset off. Might anyone be able to provide some suggestions/ideas about this?
Danny
  • 10,956
  • 3
  • 27
  • 34
803
votes
6 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
  • 9,878
  • 7
  • 24
  • 45
681
votes
35 answers

How do I ignore an error on 'git pull' about my local changes would be overwritten by merge?

How do I ignore the following error message on Git pull? Your local changes to the following files would be overwritten by merge What if I want to overwrite them? I've tried things like git pull -f, but nothing works. To be clear, I only want to…
mae
  • 12,340
  • 8
  • 28
  • 40
644
votes
17 answers

Is it possible to preview stash contents in git?

I often put work away for later, then other stuff comes along, and a few weeks later, I want to inspect the stash, and find out what changes it would make if I applied it to working tree in its current state. I know I can do a git diff on the stash,…
Benjol
  • 57,639
  • 51
  • 180
  • 252
605
votes
7 answers

git stash apply version

I have 2 branches: master | design Working in design I did a stash and switched to master, made some adjustments. Switched back to design and did a stash apply only to lose all my changes in the design branch. I am hoping all my work is within a…
Lee
  • 17,158
  • 23
  • 71
  • 97
1
2 3
40 41