I have some work in the index ready to be committed, and some changes in the working tree.

Now Ive been asked to commit now the changes in the working tree (on master) and later the work currently in the index (in a different branch). Is this possible?

有帮助吗?

解决方案

It should be possible:

git stash --keep-index
git commit -m "work in progress"
git branch wip
git reset --hard HEAD~
git stash pop
git add .
git commit -m "commit now the changes"

The work currently in the index is now in branch wip.
The changes (not added to the index) are stashed first (hence the --keep-index)

And the index of the branch you were in initially represents the changes you were working on and that you can commit on master.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top