Generally, you can check http://git-scm.com/docs/git-rebase , go to item SPLITTING COMMITS.
And better, read following thread as reference also, especially the answer gets the most votes http://stackoverflow.com/questions/1440050/how-to-split-last-commit-into-two-in-git
Play around, you will get it.
//TODO, make a example here
That is quite handy, when you forget to save you changes incrementally.
I will tell a story to show how useful it can be.
In the beginning
You write a lot of code, test, debug, finally all test case passed. What's the next thing you are going to do, usually save all the changes into a safe place, in case you would delete it by accident - or you just commit it.
But what if someone report a bug to this commit?
You don't have any idea why this issue can happen. But you want to figure out which statement cause this issue. You might revert your changes 50%, if problem still there, revert your changes 25%, otherwise 75%. With this way, you can narrow down the scope of the code which contains the bug. Without version control tool, you might save the code for (25%, 50%, 75%, 100%) into different directories. Classic! right ? And you still need to copy this changed files into your workspace, that you can build a binary.
Git save you in this case, you can split one commit into several small ones as you want. When you want to test these small commits, just 'git checkout'. Safe and clean!
No comments:
Post a Comment