문제

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