https://stackoverflow.com/a/48156644/156458 says
So you've
git add
-ed your changes, so they are currently staged. First you want to unstage them withgit reset HEAD .
assuming you are the top level in your directory. The files should all be (most likely) red now, indicating there are unstaged changes.Now you can
git stash
those changes while you create a new branch.git checkout <<master branch name>>
thengit checkout -b <<new topic branch name>>
.You've got a clean copy of master now, so let's get those stashed changes with
git stash pop
. Now you're back to where you started, with all your already committed changes in the trunk and your new changes ready for commit.
Why "you want to unstage them with git reset HEAD
"?
What does git stash
push? Does git stash
stash working directory only , or both working directory and index?