I’ve been wondering if it was possible to modify a commit or merge multiple commits in a local git repository. Of course, the answer was only a google1 away. You can’t do this once you’ve pushed your commits upstream, but that’s okay.
There are some good reasons for doing this. The most obvious is probably if you make a mistake in the comments. I like to try to make my commits completely atomic, meaning whatever change I’m making is completely implemented within a commit. This is pretty easy to accomplish if you’re willing to just not commit until you’re done. However, if you have to wait to use your version control system, you’re completely wasting the value of having a local revision control system. If you want to try something out and you’re using git, you can commit, branch, commit, merge, etc. Once you’re happy with your solution, you can package all that stuff into a single, or set of, tidy commits that each make a single, atomic, change.
1 google is used as the noun form of the verb “to google”, not the proper noun “Google”.