Member-only story
Six Lesser-Known Git Commands to Make Your Life Easier
I wish I had known them sooner.

I was going through some random content on google and stumbled upon some git commands which can make your life easier.
I have spent hours doing some of the tasks manually mentioned below.
So, let’s get on with it.
Updating Your Last Commit Message
We all have experienced noticing a typo message in our commit just after hitting the enter button.
It is often frustrating and makes you look unprofessional.
git commit --amend -m 'Updated message'
Using the command, you can edit your last commit message easily.
Blank Commit
I have found cases where I want to commit, but no files are added, changed, or deleted. In this case, I had to make some changes to commit anything.
But, it is not the case anymore.
git commit -allow-empty -m "No changes made"
Using this command, you can commit without any changes. It may be helpful when you need to trigger a build step or start a new branch.
Staging and Committing in a Single Command
I spent countless minutes typing in two commands whenever I had to commit by adding all the files.
git commit -am "commit message"
Using this command, you can add all the changed files and commit in one go. I have been using it a lot after getting to know it.
Checking the Total Number Of Commits
If you ever want to check the total number of commits on any particular branch in your repository, you can use the following command.
git rev-list --count <branch-name>
Note that by default, the name of the branch is main
.
git rev-list --count main
Git Tutorial In Terminal
Now, if you forget the exact syntax for some task, you can quickly type in —
git help tutorial
to pull out the basic commands like a cheatsheet. It can save a lot of time where you don’t have to google and go through websites.
If you are new here and liked the article, there are many more like this on Medium. You can sign up to read them for just $5 a month.
Here is the link for unlimited access to every content here on Medium. If you sign up by using this link, I’ll earn a small amount at no additional cost to you.