So this week, was the annual PowerShell Summit in Bellevue, WA. I think the number was around 230 attendees, not including speakers. So many smart and funny people around the world came to one place to hear what Microsoft and the community are doing next with PowerShell Core (6.0), technologies and companies working with Powershell, DevOps in general, and solving solutions.
What did I get from it as a developer? Besides spending time with friends in the industry, I was able to meet people like Jeffrey Snover, Lee Holmes, and Bruce Payette. Meeting up with friends like Don Jones, Jason Helmick, Missy Januszko (@thedevopsdiva), Jeff Hicks, Richard Siddaway, Steve Murawski (Chef) and so many others I’ve met over the years, the conversations gave me inspiration and ideas for how I can not only make my personal projects better and more efficient, but also help with solutions to problems I didn’t yet know I had!
Now the meat of the story. Ansible, Python, and virtualenvs have been my life lately, and after talking to some guys at AWS, the awspowershell module sounds like it would simplify my personal dev workflow. 😀
So, being a beginner to git and its associated commands and check ins, I needed a way of “squashing” the 15 or so check ins into one so others can see one checkin versus my save-a-holic-ness. I save a lot, whether it’s video games or code, and that includes commits to my local history. Squashing is combining commits into fewer to make the history much more readable. How does one squash their commits? With this magic command.
git rebase -i HEAD~3
This is what it does. The rebase command basically rewrites the local history (make sure you’ve not pushed to a remote repo though! You don’t want to mess up history for others) The -i makes it interactive, usually opening in your local editor or vi as a default for most OSes, and yes this includes Windows if you’ve installed git on Windows with the bash shell. The HEAD~3 part (no spaces between HEAD and ~3 though, and that is the tilde character before the 3), takes the local head and goes down 3 commits. Change the entries to “squash” and include in the check in.
After that, “:wq” to write the changes if using vi, git commit and merge with your upstream repo.
The Google search results in a simpler explanation: “ Use git rebase -i <after-this-commit> and replace “pick” on the second and subsequent commits with “squash” or “fixup”, as described in the manual.”