|
|
|
|
|
by u801e
1599 days ago
|
|
I've found that separating work from recording that work is the easiest approach. So what I end up doing is waiting the code and tests and making sure things work as expected. Only then will I start recording that work into a sensible series of commits. To do this, I'll generate the diff of my work relative to the base branch and then stage parts of that work using the git apply command and make a commit out of it. If it turns out that I need to update what I changed in a commit I already made, I'll just make a fixup commit (by creating a commit with the changes and titling it with fixup! Exact title of commit
This way, when I run a rebase with the autosquash parameter, git will rearrange the commits such that the fixup commit is listed right after the commit I want to amend.If I just need to update the commit message itself, I'll do the same thing except that I use the squash! prefix instead of fixup!. I then make the commit using the allow-empty option (making sure I have no changes states in the git index). During the autosquash rebase, this brings up the editor where I can delete the text except for the updates commit message I typed earlier. |
|
What about making smaller commits and going back and editing it later? You could either 'git reset --soft' to "undo" some commit(s) and then craft them how you like, or anything else. Seems like your git skills should easily be good enough to handle that.
By the way, you know about 'git add -p', right? That's a fancier way to do what I think you're doing with diff and apply, though yours may work better for you.