DEV Community

Krinskumar Vaghasia
Krinskumar Vaghasia

Posted on

Git Squash on terminal

This week for lab 5, we were supposed to refactor the open source project that we have been working with. After a lot of contributions from others students, the code base was expanded and it was about time some refactoring was done.
So here I am refactoring the code and learning git's squash and merge feature at the same time. This lab was very open ended with how we wanted to refactor the code, So I decided to do it by making more functions, enhancing the variable names and lastly separating the logic into different files.

Making more functions

There was some logic that I felt can be extracted into functions. Like the logic responsible for parsing the TOML file.

Better variable names

After a lot of changes this past month, there were a lot of variables with similar name that resulted in some confusion. I updated those variable names in this commit.

Making more files

Finally, I took all the logic that was responsible for parsing the arguments and bundled it into a new args.js file, and updated the imports accordingly in the command.js file.

All of these changes were one commit and in total I made three commits for the three changes. After the coding part was done, I squashed using the git rebase main -i command which opened an interactive VIM editor for me to manage my squash. This resulted in a new commit that squashed all of my three commits. I then merged this to main and pushed it to origin.

I learned how to squash all of my different commits into one this week, until now I was relying on the githubs squash and merge feature while making PRs.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Generate and update README files, create data-flow diagrams, and keep your project fully documented. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay