I totally love git add -p
and git stash
but I occasionally have the following problem, which is reproduced by the following sequence of commands:
To create and test an index containing part of the working tree changes, including manually edited hunks, do:
git add --patch
git stash --keep-index
git reset --hard
git stash pop --index
At this point there are no conflicts, and the repository, index, and working directory are in the state immediately preceding the git stash
. You can now git commit
the indexed changes.
Of course, this is rather weird and not very intuitive and I would really like to know whether there is an easier way to do this.