Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does "git stash apply" or "git stash pop" also adds the modified files for commit?

Tags:

git

I made few changes in local master branch. The local changes were not staged (added). In order to update the master branch, I did the following:

  1. statshed my local changes.
  2. git pull
  3. git stash apply

I see that after this the local changes get staged (added) ? Shouldn't they be kept unstaged as they were before.

like image 650
Karun Avatar asked Sep 11 '13 12:09

Karun


1 Answers

git stash is essentially the same as git commit. It creates a fully fledged commit, but doesnt add it to the history. Instead, it adds the commit to the stash.

Therefore, git stash has to make a choice: Either commit (stash) all the uncommited changes, or only commit (stash) the ones that are added to the index. It can't do both. That would take two commits instead of one.

AFAIK, git stash takes all uncommited changes.

like image 136
functionpointer Avatar answered Sep 19 '22 12:09

functionpointer