I went into a branch and did some work. I wanted to go into another branch but didn\'t want to commit so I did git stash
. Then I did git checkout
git stash
is not per-branch.
git stash
(which can be lost easily when you have lots of stashes and branches) git commit
to save the unfinished code in your branch and when you are ready to finish the code do a git reset ${COMMIT_HASH_VALUE}
to get the unfinished code backgit commit
and git reset
when used together correctly can simulate a git stash
for a specific branchHere is a common real-life scenario that demonstrates the value and the usage the commit
and reset
commands:
git commit
on feature branch X
COMMIT_HASH_VALUE
for latergit reset ${COMMIT_HASH_VALUE}
(FYI the default for git reset
is --mixed
)