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
867
votes
39 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
  • 14,947
  • 8
  • 32
  • 47
825
votes
18 answers

How do I preview stash contents in Git?

I want to inspect a 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, but this shows me all the differences between the working tree and the stash, whereas…
Benjol
  • 63,995
  • 54
  • 186
  • 268
811
votes
8 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
  • 20,034
  • 23
  • 75
  • 102
718
votes
18 answers

How can I stash only staged changes in Git?

Is there a way I can stash just my staged changes? The scenario I'm having issues with is when I've worked on several bugs at a given time, and have several unstaged changes. I'd like to be able to stage these files individually, create my .patch…
MrDuk
  • 16,578
  • 18
  • 74
  • 133
693
votes
13 answers

How to resolve git stash conflict without commit?

As asked in this question, I also want to know how to resolve a conflicting git stash pop without adding all modifications to a commit (just like "git stash pop" without a conflict does). My current approach is very uncool because I do it this…
Sven
  • 7,335
  • 4
  • 15
  • 14
554
votes
10 answers

How to unstash only certain files?

I stashed my changes. Now I want to unstash only some files from the stash. How can I do this?
morpheus
  • 18,676
  • 24
  • 96
  • 159
539
votes
16 answers

How to abort a stash pop?

I popped a stash and there was a merge conflict. Unlike the question that is listed as a duplicate, I already had some uncommitted changes in the directory which I wanted to keep. I don't just want to make the merge conflict disappear, but also to…
Casebash
  • 114,675
  • 90
  • 247
  • 350
522
votes
10 answers

How to Git stash pop specific stash in 1.8.3?

I just upgraded Git. I'm on Git version 1.8.3. This morning I tried to unstash a change 1 deep in the stack. I ran git stash pop stash@{1} and got this error. fatal: ambiguous argument 'stash@1': unknown revision or path not in the working tree. …
Jesse Atkinson
  • 10,586
  • 13
  • 42
  • 45
492
votes
5 answers

Stash just a single file

I'd like to be able to stash just the changes from a single file: git stash save -- just_my_file.txt The above doesn't work though. Any alternatives?
EoghanM
  • 25,161
  • 23
  • 90
  • 123
479
votes
6 answers

Git Stash vs Shelve in IntelliJ IDEA/Netbeans

I am very unfamiliar with the shelve aspect of Git (EDIT: not an aspect of Git, but rather IntelliJ IDEA feature of shelve). If stash is used to put aside unfinished work what is shelve then? What would you use it for? For example on Update Project…
Subtubes
  • 15,851
  • 22
  • 70
  • 105
373
votes
16 answers

How to stash only unstaged changes in Git?

I would like to use this workflow: Stage some changes. Save the unstaged changes to the stash. Do some stuff with the things in stage (build, test, etc.). Commit. Restore the unstaged changes. Is there a way to do step 2? Example: git init echo…
Unapiedra
  • 15,037
  • 12
  • 64
  • 93
352
votes
3 answers

Get the creation date of a stash

Is there a way to tell when a stash was created? git stash list only lists the stashes, and git stash show XXXXXX shows all the files and changes, but not the date of the stash creation.
Jason Lawton
  • 4,412
  • 3
  • 21
  • 20
318
votes
13 answers

How to reverse apply a stash?

I have a small patch saved away in my git stash. I've applied it to my working copy using git stash apply. Now, I'd like to back out those changes by reverse applying the patch (kind of like what git revert would do but against the stash). Does…
Pat Notz
  • 208,672
  • 30
  • 90
  • 92
308
votes
11 answers

How can I rename a git stash?

I have a stash with an incorrect name. I would like to fix the name so it's accurate. How can I rename a stash?
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
277
votes
13 answers

Is it possible to push a git stash to a remote repository?

In git, is it possible to create a stash, push the stash to a remote repository, retrieve the stash on another computer, and apply the stash? Or are my options: Create a patch and copy the patch to the other computer, or Create a minor branch and…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
1
2
3
44 45