Skip to main content

How to become a GIT Guru? The most common mistakes and their solutions

About Us
Published by jetbi
31 October 2022

How often does it happen when you have been working on a project for a long time, have already made a bunch of changes, and have almost reached the goal but suddenly something irreversible happens? Maybe you committed the changes to the wrong branch or a merge conflict appeared... Now the panic attack is getting you. Familiar feeling? You are not alone: this is quite a common situation for every developer.

As you have already guessed, we will discuss the version control system today, specifically using GIT as an example. Developers from all over the world use this tool in their work on a daily basis. Still, many of them don’t give much attention to this topic, use only the most common commands, and don’t even know about half of the possibilities that GIT provides.

Sometimes, due to the lack of proper experience and knowledge, unexpected situations happen and people immediately start to panic and, therefore, make a lot of mistakes until they reach the point of no return. In such situations, you mostly don’t even suspect that the solution lies on the surface. So, let’s find the solution. Once Leonardo Da Vinci said, "Simplicity is the ultimate sophistication". And it's true!

I want to say you are truly lucky today! Why? Because I'm about to give you a pill that will relieve your constant "headache," save you a lot of nerve cells when working with GIT and help you understand what Leonardo Da Vinci meant. All you gotta do just read this article until the end. Well, here we go!

Today we consider the top 3 the most common mistakes and their solutions:

1. Commit error. Have you just created a new file and made changes to the old one, but forgot to add something to the commit? Or maybe you made a mistake in the comment? All you need is to use the git commit --amend. Running this command will open a default text editor where you can edit the commit message. After exiting the editor, the description of the commit will be changed.

2. Committed changes to the wrong branch. You have been working on a new task for several hours, making more and more commits, and suddenly you realized that you have been doing these things in the master branch all that time… Just, please, don't panic, it could be fixed, just enter the following commands:

git branch future-brunch

git reset HEAD~ --hard

git checkout future-brunch

3. Desperate situation. If you understood that you have made too many mistakes and hundreds of new changes are not valid, even in such a situation there is a very simple solution. Here you will come to the aid of such a command as git reflog. Using this command you can go back in time, undoing almost anything done in GIT. Even if it was reset.

Congratulations, now you're almost a GIT guru! Now you understand when working with GIT there is nothing to worry about and everything can be fixed. If you want to learn more about this topic, then I suggest you follow this link:  10 Common Git Problems and How to Fix Them. Thank you for your attention, we’ve done it! Whoo!


You can find more interesting articles here:

Daria Daineka
Junior Salesforce Developer
Question to the expert

We have available resources to start working on your project within 5 business days

1 UX Designer

1 Admin

2 QA engineers

1 Consultant