What’s this weird sounding thing called Git? Is it Git or just git? What does it do, who uses it, and is it actually useful? In this post, you’ll learn all you need to know about git (yes, it’s just git!).
Photo by Leo Rivas-Micoud on Unsplash
At work recently, our CTO noticed that our main repository’s
staging branch had over 80 less commits than
master. That shouldn’t be the case, because our deployment pipeline has always been to go from
master. Code that exist on
master must therefore already exist in
No, turns out nothing was really wrong. It’s just that whenever we close a pull request (PR) on GitHub, our team protocol is to hit the “Merge” button, which merges all the commits from the PR into
master, but not without adding one extra commit at the top called the “merge commit”. Each PR created one extra commit on
master. That was the reason for the commit count mismatch.
Photo by NeONBRAND
Use case: You want to switch to a different branch on the same project (say from
staging), but you have uncommitted changes and git insists you commit before switching branches.
In this short post, I’ll demystify the process to squash git commits from the command line. This process is simple if you’re using a remote like GitHub, which can be done with the click of a few buttons in the Pull Request UI. This post focuses on squashing commits on the command line.
Note before proceeding: I use Terminal on a Mac and the commands below are based on that.
Photo by Vance Osterhout on Unsplash