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
46
votes
3 answers

Is it possible to use git stash command from Visual Studio

I'm using Visual Studio 2017's Team Explorer to work with a git repository. Every time I'm uses the git stash or git stash pop, I need to open the Git Bash console and navigate to my project folder and run the commands. Is there any way to stash…
Shahar Shokrani
  • 7,598
  • 9
  • 48
  • 91
45
votes
2 answers

How to view stash date/timestamp next to stash id?

Using git stash list shows me the list of stashes with their IDs. Using git stash list --date=local or git stash list --date=relative gives me their times, but I have no idea what their corresponding ID is. I want to acquire a stash at a certain…
LazerSharks
  • 3,089
  • 4
  • 42
  • 67
44
votes
4 answers

Pull is not possible because you have unmerged files, git stash doesn't work. Don't want to commit

I just want to pull. I have changes to disregard, my Gemfile and Gemlock files and I'd be happy to just overwrite them and just pull. I tried stashing my changes away, this didn't work out for me. What do I do? git pull M Gemfile U …
JZ.
  • 21,147
  • 32
  • 115
  • 192
44
votes
3 answers

git stash and apply

I'm new to git and not quite clear on how stashing works. Let's say I'm working on branch master and try to git pull and receive the error that my local changes would be overwritten and need to be stashed or committed. If I haven't staged any of my…
neridaj
  • 2,143
  • 9
  • 31
  • 62
40
votes
2 answers

git stash and pop shows file no longer marked as moved?

git mv file1 file2 git status # On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # renamed: file1 -> file2 git stash git stash pop # On branch master # Changes to be committed: # (use "git reset…
Andy Ray
  • 30,372
  • 14
  • 101
  • 138
39
votes
1 answer

How to stash in Visual Studio 2022?

There is no way to use git stash here, except apply and pop
DevLife
  • 519
  • 1
  • 4
  • 6
38
votes
2 answers

What happens if I stash changes in a branch and then delete that branch

What happens if I stash changes in a branch and then delete that branch? (1) Do I lose the stashed changes? Example: git stash git checkout other_branch git branch -D previous_branch (2) Also, are the above stash and delete steps equivalent to…
Pranjal Mittal
  • 10,772
  • 18
  • 74
  • 99
37
votes
2 answers

How do you “update” a stash?

In my current branch I have several stashes: stash@{0} stash@{1} stash@{2} If I apply stash@{0}: $ git stash apply stash{0} Modify this stash I want to save the changes to the current stash stash@{0} I don't want to create a 4th stash I just…
Nick
  • 19,198
  • 51
  • 185
  • 312
35
votes
1 answer

What's a `WIP` on a stash commit?

What's a WIP means on a stash commit? $ git stash list stash@{0}: WIP on master: 049d078 added the index file stash@{1}: WIP on master: c264051 Revert "added file_size" stash@{2}: WIP on master: 21d80a5 added number to log I'm just curious.
Asim K T
  • 16,864
  • 10
  • 77
  • 99
35
votes
3 answers

Stash the changes made with atlassian sourcetree

I have a lot of files changed in my project. I want to stash 2 files but i'm a bit afraid to make a mistake since i never did this. If i would stash now, will it only stash the 2 staged files? And if I don't mark the "Keep staged changes", will it…
clankill3r
  • 9,146
  • 20
  • 70
  • 126
34
votes
6 answers

`git stash` during a merge conflict

We've done something bad. We ran git stash save during a merge conflict, and now we can't restore our work. Things we've tried: git pull -Xours origin master git stash apply --index And: git pull origin master git stash save --keep-index "merge…
steven_moy
  • 341
  • 1
  • 3
  • 3
34
votes
4 answers

How do I add further changes to a stash in Git

Suppose that I have stashed some changes and I want to add further changes into the same stash (such as stash@{0}). Is there an easy way to do this? What about combining two stashes into a single one?
Casebash
  • 114,675
  • 90
  • 247
  • 350
33
votes
1 answer

"Too many revisions" git message

On git version 1.7.9.5, when trying git stash show -p stash@{"Friday Smarch 13 13:13:13 2013"} (from Is it possible to choose a git stash when they're described by the date stashed? ) I get the error message Too many revisions specified:…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
33
votes
2 answers

How can you unstash changes using EGit?

When I switch branch with non-committed changes I'm given a prompt to stash my changes: When I switch back to the branch with the stashed changes I can't see any of the non-committed changes. Using EGit how can I retrieve the stashed changes?
Edd
  • 8,402
  • 14
  • 47
  • 73
32
votes
4 answers

Turning off the pager in git for the stash command only

I generally like the use of the pager in git, but for git stash the pager annoys me. When calling git stash list, I don't want to be shown the three lines of output in the pager -- it forces me to press q just to make the output unavailable again…
Sven Marnach
  • 574,206
  • 118
  • 941
  • 841