Git commands nobody has told you

Svetloslav Novoselski
Bootcamp
Published in
3 min readApr 19, 2022

--

Git plays an important role in our daily routine as software engineers, especially working in a team. It helps developers to collaborate on projects no matter of the scale. There are a lot of git commands available, some of them developers use every day, others aren’t use that widely but it’s worth to know about their existence.

In this article we are going to see some commands which aren’t required to know but will definitely help us become git guru.

Add and commit in one command

One of the most used command in git is git add, followed by git commit.

git add .
git commit -m "commit message"

Most of the time will want to add all changed files. Instead of writing both commands we can combine them in one using the -am flag, which is doing both git add . and git commit.

git commit -am "commit message"

Copy changes from another branch

There are some scenarios where we have to add changes to more than one branches, for example if there are two versions and we support both of them, we should commit changes to both branches.

Let’s have two branches, branchA and branchB. Instead of committing in both branches manually, we can use git rebase command.

--

--