Useful git tools & functionalities

Mario Gunawan
3 min readSep 8, 2022

--

this article is directed towards people that have learned about basic git commands, and want to learn more about git

If you’re a programmer, chances are, you are using git as your version manager tool. Despite being one of the most popular version manager currently used, there is a lot of hassle from using git, from typing human-readable commit message, to merging a ton of codes. Here are some extra git functionalities that might help you do your day-to-day git stuffs!

Git alias

Git alias helps you to shorten a git command, take for example:

git config --global alias.c commit

This will turn your git commit command to just git c ! You can also add flags to your most used command, for example:

git config --global alias.cob "checkout -b"git config --global alias.lol "log --oneline"

By wrapping commands that are separated with space with colons, you can get more out of your config alias

Another useful tips is to also make an alias for git in your computer, in mine, I use g as an alias. You can create an alias for your git in any operating system, just google it!

Git reset

Git reset will helps you to reset to the previous commit. If you found yourself having a buggy program, this will helps a lot. git reset have two main flags, hard or soft.

git reset --hard HEAD~Nwill reset to the previous N commits and deletes the changes that you’ve made during the last commits

git reset --soft HEAD~N(default) will reset to the previous N commits but it keeps the changes

For example you have commits log like this:

189jdio #69 - Another bug
d9asjio #68 - Oops a bug
djs0b89 #67 - Finish the app
37sads8 #66 - Feature #13
8gya9ap #65 - Created todolist state
asd3212 #64 - Manage user authentication

And you want to reset to the Finish the app commit and deletes the changes you’ve made since then, then you need to

git reset --hard HEAD~2

Pre-commit

Pre-commit is a tool that make your computer executes something before changes are commited. If you have a team that have different coding styles, you might want to add pre-commit which executes some code formatting so the codebase looks cleaner. Currently, there are two pre-commit configuration that I can reccomend:

After that, you must configure yourself for what kind of purpose you want your pre-commit tool to be. To format your codes? To run test cases? To try and build your app? Whatever you need is, pre-commit will help you make sure that every commits follow your team’s rules and standards.

Github/Gitlab Issues

OK this one might not be directly related to git, but it’s really useful to know this.

When you’re working on a project, we are usually forgetful about the bugs that we have found, or the features that will be good for the application. After thinking about it, we usually forget about it again. This creates a loop of never-ending code smells and list of ideas that were thrown away just because we couldn’t keep track of our findings.

And that’s why, the two major online git repository service offers the issues page, where you could put any issue that you’ve found in the program. This makes it easy to remember and gives you a rewarding feeling when you finally finish an issue. Even better, you can also start targetting how many issues or features are you doing in a day to make you more productive as a developer.

I usually use this tab when I find any interesting ideas, bugs, etc. and it really helps me in managing my time and also my motivation to code.

Hope this article helps you. Have a good day!

--

--

Mario Gunawan

I'm a mobile / web developer. I'm mostly writing articles about software development.