3 ms·
How do you build up the incremental changes? By staging them into your working directory from the one giant commit?
by jsolson 8y ago
How do you build up the incremental changes? By staging them into your working directory from the one giant commit?
- kazinator 8y agoHuh? In the obvious way: $ git commit --patch ... pick out changes: commit 1 ... $ git commit --patch ... pick out changes: commit 2 ... $ git commit --amend --patch ... pick out more changes into commit 2 ... $ git commit --patch ... pick out changes: commit 3 ... There, now we have three commits with different changes and were never aware of any "index"; it was just used temporarily within the commit operation. Oops, the last two should have been one! --> git rebase -i HEAD~2, then squash them. The index is too fragile. You could spend 20 minutes carving out very specific changes to stage into the index. And then you do something wrong and that staging work is suddenly gone. Because it's not a commit, it's not in the reflog. You want changes in proper commit objects as early as possible, then massage with interactive rebase, and ship. Suppose HEAD points to a huge commit we would like to break up. One simple way: $ git reset HEAD^ Now the commit is gone and the changes are local. Then just do the above procedure: commit --patch, etc.
- sigjuice 8y agoThanks for 'you want changes in proper commit objects as early as possible'. I can't tell you how much time I have wasted with a botched index.