开发者

Reorganizing hunks into commits

I have made a major refactoring of some code, and in the process I have commited several ti开发者_如何学运维mes. This has not been pushed to any public repo yet. Before pushing, I would like now reorganize the commits into logical units. The problem is that I want not only to squash commits but to reorganze the hunks into other commits.

Just to make it clear, I have commit A with hunks A1, A2, A3, and commit B with hunks B1, B2, B3. I want to checkout the version previous to A and have new commit C with hunks A1, A2, B2 and a new commit D with hunks B1, B3, A3.

Thanks in advance.


Take a look at git rebase, splitting commits.


It sounds like you want a completely different sets of commits. If that is the case, simply got back to the origin (e.g. git reset origin/master), and then use git add -p and git commit repeatedly until you are done. You can use git stash to test each commit after committing, if desired, and use git --amend to fix any mistakes.

Alternatively, git rebase -i can actually split commits. Read the man page, it's not hard but a bit bothersome.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜