Reputation: 6637
If I stash changes using git, will it only stash uncommitted files, or will it stash everything that hasn't been pushed to git?
Upvotes: 1
Views: 178
Reputation: 520948
The answer to your question is that Git will stash everything which has not been committed to your local branch.
When you do a git stash
, it actually makes two temporary commits. The first one contains the files which you have staged (i.e. by doing git add
on them). The second one actually contains your working directory files.
When you do a git stash apply
, Git will reinstate the working directory. However, if you do git stash apply --index
, then it will also try to reinstate the index (i.e. your staged files).
So git stash
cleans the slate, and leaves both your stage and working directory in the state they were at your most recent commit.
Upvotes: 2
Reputation: 7100
From the git stash
documentation:
Stashing takes the dirty state of your working directory – that is, your modified tracked files and staged changes – and saves it on a stack of unfinished changes that you can reapply at any time. Source
Upvotes: 0
Reputation: 881203
It will stash the dirty state of your working directory, specifically tracked files that have been modified and changes that have been staged but not yet committed.
It is not necessary to save committed files since, well, they've been committed. So if, by "pushed to git", you mean local commits that have been pushed to a mirror/origin repo, they won't be saved either (because they've already been committed).
Upvotes: 1