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
23
votes
2 answers

What is the purpose of git stash create and git stash store?

From the documentation at git-scm, there are two git stash commands that mention relevance to scripting, but not general use: create Create a stash (which is a regular commit object) and return its object name, without storing it anywhere in the…
BlackVegetable
  • 12,594
  • 8
  • 50
  • 82
23
votes
3 answers

Git: how to use stash -p to stash specific files?

I'm trying to figure out how to stash two specific files among many uncommitted changes. This very promising answer, Stash only one file out of multiple files that have changed with Git?, doesn't show the usage and I'm having trouble working it…
doub1ejack
  • 10,627
  • 20
  • 66
  • 125
23
votes
6 answers

stashed some code but don't know which stash it is in - how to figure out?

I wrote considerable code for a feature and stashed the changes in git. After that I pushed several changes into the repository and did a git stash and apply multiple times (read over 100 times). After almost 2 months I now want to retrieve the…
user811433
  • 3,999
  • 13
  • 53
  • 76
23
votes
2 answers

Git stash: How to see if there are stashed changes in a branch

Let's say i'm in a branch off of master, called "my_new_stuff". I have a feeling i might have stashed something in there. I'm worried that if I do git stash pop and i didn't stash anything it's going to shove a load of unwanted crap into my…
Max Williams
  • 32,435
  • 31
  • 130
  • 197
22
votes
4 answers

git: move stash to repository in another directory

I have a local stash on a directory. For some reasons, I had to re-import the same remote project into another directory. Is there a way to move my stash from my old directory to the new created one since they follow the same remote project and…
Magnas
  • 869
  • 1
  • 5
  • 18
22
votes
3 answers

Git stash with staged files. Does stash convert staged files to unstaged?

I was working on a large set of changes to a code base. Some of the changes had been staged, and some had not. I needed to switch to a different branch, but was not ready to make a commit, so I stashed my current state using git stash. Later, I went…
Jeff Fohl
  • 2,047
  • 2
  • 23
  • 26
22
votes
4 answers

How do you stash only files that have been added?

For example, a git status gives the following: Changes to be committed: (use "git reset HEAD ..." to unstage) modified: app/src/[....] modified: app/src/[....] new file: app/src/[....] deleted: app/src/[....] …
peter-b
  • 4,073
  • 6
  • 31
  • 43
21
votes
2 answers

git - errors after merge conflicts during stash pop

Original title: git - update all files that have not been changed Currently I am trying to update all files in a git repository that have not been changed. Lets say for example I have: test1.py test2.py test1.py has been modified locally while…
ftiaronsem
  • 1,524
  • 4
  • 19
  • 32
21
votes
4 answers

git-stash changes without reverting

I work on a project using Git. Every once in a while I find myself wanting to save my changes, without committing them, just as a backup, and then continue working. What I usually do is git stash and then immediately git stash apply to bring the…
opetroch
  • 3,929
  • 2
  • 22
  • 24
21
votes
2 answers

What is a stash?

I have googled and searched in various places for a while, but have not found a good answer. What is a stash, and what is it used for? (Source of confusion: using beautiful Fuel with Fossil, clicked the "Stash changes" button, see files in there…
Ralf
  • 598
  • 1
  • 7
  • 17
20
votes
1 answer

Stash only some of the currently modified files

I have many changed files and would like to stash only some of the modified files. As an example, my repository looks something like: Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout --…
Increasingly Idiotic
  • 5,700
  • 5
  • 35
  • 73
19
votes
4 answers

Git stash two branches

This is the situation: I made changes on branch A git stash on branch A git checkout B Made changes on branch B git stash on branch B git checkout A git stash pop on branch A After step 7 of the list above, the changes I had made on branch A…
Gabriel Ferraz
  • 592
  • 6
  • 26
19
votes
1 answer

Can I git stash a merge in progress?

I'm in the middle of resolving conflicts for a git merge, but I want to get back to a clean state temporarily without losing the work I've already done on the merge. If I try to git stash, I get errors for each file for which a conflict has not yet…
Russ
  • 1,931
  • 1
  • 14
  • 15
19
votes
3 answers

Can I fetch a stash from a remote repo into a local branch?

A colleague has a stash in their repository which I can access (via the filesystem), and I'd like to pull that stash into a branch in my repository. % git ls-remote ~alice/work/repo/ stash 3ccc82fb1ee0e7bde1250c7926d333ce21c109c0 …
Matt Curtis
  • 23,168
  • 8
  • 60
  • 63
19
votes
3 answers

Stash selected files with Git Extensions

Is there a way with Git Extensions to only stash some of the uncommitted files? Say I have three files changed in the working dir (uncommitted) but I only want to stash 2 of them. FYI It doesn't seem to matter whether the uncommitted files are…
Cincinnati Joe
  • 2,077
  • 6
  • 23
  • 32