In Lab 5 we are tasked with refactoring our code and committing our changes to a new branch and then squashing the commits with a rebase and amending commit comments to reflect our changes. It goes a little something like this:
First I created a new branch called
refactoring based off
master and began refactoring code. I ended up extracting a piece of code which ignored urls and turned it into a function which returns and array rather than modify an existing one. I then took all the functions, structs and global flag variables and put them into a
utils (utilities) folder as I took a scripting approach by shoving all the logic into a single file, cause you know.. why not? Anyway, every change I made I would commit them to my local repository and when the refactoring was complete I was ready to squash my commits and push it to github.
First I ran
git rebase master -i whilst on the
refactoring branch and was provided with a menu that allowed me to ‘pick’ and ‘squash’ commits. The first commit is mandatory to be picked so I let that option alone and ‘squashed’ the rest of my commits. Now all my commits are squashed into a single commit but my commit message is misleading so I run
git commit -amend and am treated to another menu where I can change my commit messages, so I changed the first commit message (the commit I squashed my other changes into) to something more clear.
I checked my
git log to see the changes made and saw all my commits and what it was squashed into and was able to checkout back to
master and merge it with
refactoring and push it to the master repo.
Once pushed my final
git log looked something like this:
Maybe I should clean up my PRs with this newly found power…