Git : Rebasing Refactoring Amending

As if I still don't know everything about git. This week learn about rebasing and amending, rewriting git history as the prof described it. So let's say you're writing a word document and you're in the editing phase. You violently mash Ctrl+S every time you make a small fix. Adding punctuation, deleting a word, making a new line, you save again and again and again. Now imagine if you had a log for every time you save that file, like a git commit. Now that's a lot of entries, and we as coders do this with git commiting as well, but with git saving and tracking each one of those commits, our logs get a bit convoluted and messy. That's why git rebasing and amending is here to save the day.

So for this week's lab our prof wanted us to practice these new git concepts by polishing our code and git commiting to our hearts content, since we will be rebasing in the end. So I made my changes and made a couple of commits to the code. Once I was satisfied with the changes it was time to do a interactive rebase. P.S. I keep forgetting to screenshot actual progress of these labs so don't mind the throwaway branch and commits for the sake of visual examples.


Interactive Rebase
Amend
  
The interactive rebase is quite a useful way to edit your past commits with a lot of options and functionalities, the generated git file you interact with is quite a neat tool. For the lab, we were instructed to pick our first commit and squash the rest, which basically means that all the commits will be merged into one. After that amending it to edit the name to indicate the 3 commits in a better format. After that the branch is ready to be merged with the master.





I wish I knew about this feature even a week earlier, my last PR to a repo was filled with 3 commits since I keep finding small discrepancies that I make a new commit for, to the point that I just stopped making edits to not clog up the commit for the PR. Anyways, I see myself git rebasing/amending a lot in the future. 

To Git-ting better at git.

Thanks for reading.

Comments

Popular posts from this blog

HacktoberFest Entry No.2

Lab 1 : Our First Open Source Contributions

Hack.... vemberfest.. PR No. 3