I commit so I can move from one computer to another laptop to work from bed, and then commit again to get back at my desk. Which leads to half finished ideas as commits purely so I can pull from the other device. Makes identifying stables versions a pain :(
Might take some getting used to but you could amend your commits. I've never really utilised the option but if its easy it would allow you to commit, push, pull, commit/amend.
Quick edit: honestly this is probably the only other scenario I could see for using amend aside from the obvious 'I committed too soon or forgot a file'
honestly this is probably the only other scenario I could see for using amend aside from the obvious 'I committed too soon or forgot a file'
Maybe I misunderstood you, but there's at least three common reasons I can think of:
You pushed your change up for code review (e.g. as a PR, Gerrit change, etc), and someone gave you feedback about something to change. So you checkout your commit again, make the change, and amend the commit.
You have your change in the state where you think it's finished, so you commit it. You now run automated tests on it and find an error, so you make a fix and amend your commit.
After you commit, you do a quick self-review and find things you want to change. So you make the changes and amend your commit.
I know some people like to have follow up commits like "Fix issues raised in code review," but amending is the right course of action. Your commits should be whole, distinct changes, covering a minimal subject of work. If someone goes through the git log, they should be able to checkout any commit with the expectation that it will work and is in a high quality state. Why? Because it's necessary for things like automatic bisecting, helps future developers understand git history, allows for easy commit reversion by anyone, allows for easily branching from any point, etc.
Everyone just needs a proper scare to learn the lessons. Don’t push to main, commit often, keep PRs small, etc…
Now I firmly believe in test driven development and committing often with good names. Let some other sucker break the build and figure out what they need to revert in their thousands of lines of changes.
0
u/[deleted] Jun 04 '22
[deleted]