4 ms·
I didn't know about the empty commit, that's useful. The approach I try to follow is below. The BLUF is I use a similar but more granular approach and agree wi
by Communitivity 6y ago
I didn't know about the empty commit, that's useful.
The approach I try to follow is below. The BLUF is I use a similar but more granular approach and agree with writing the commit before you do the work.
First, I write the commit message capturing the intended design in a file and then try to create a skeleton of API level changes with method names and stubs from my design as my first commit. I use the file as my commit message for this.
Next, as I work I commit freely locally with small commits but I don't push to remote. I do this rather than commit --amend so I can track and revert as needed if needed. I probably could just use --amend.
Last, once I have it working I squash those commits into one commit and push to remote, then merge in changes from master if any and repush, and then start cycle over.
I tend to do this at one level below the issue I am working, so I then still have multiple commits for an issue, one per sub-issue. I will sometimes leave these as is in the PR, or sometimes I will squash these into a single commit as well. Which I do depends on how active the branch I'm targeting with the PR is, how big the commits are, and the extent of the changes.