Tech Corner

How to use Git for beginners in 2024

Megha Baweja
.
last edited on
.
August 26, 2024
4-5 mins

Table of contents

Automate your business at $5/day with Engati

REQUEST A DEMO
Try Engati for WhatsApp Marketing: Meta's Tech Partner of the year 2024
Book a Demo
How to use Git for beginners

Working with GIT version control systems always have received a mixed bag of reviews. Some find it really easy and manageable, while others struggle with working with it and look for better updates to the open project.

Today, we’re uncovering the hidden abilities of some of the GIT commands to give you more confidence in working with it. You may also get exposed to the new magical commands.

The following hacks will always keep your mind ready to play with GIT

How to Use Git for Beginners: A Step-by-Step Guide

Git is a crucial tool for developers, helping you manage changes to your projects and collaborate with others.

If you're new to Git, this guide will help you get started.

1. Understanding Git and Version Control

Git is a distributed version control system that tracks changes in your files and allows multiple people to work on the same project simultaneously.

It’s particularly useful for software development but can be applied to any project where tracking changes is important.

2. Setting Up Git

Before you start using Git, you'll need to install it on your system:

1. Windows: Download the Git installer from git-scm.com, run the installer, and follow the setup instructions.


2. macOS: Install Git using Homebrew by running the command brew install git in your terminal.


3. Linux: Use your package manager to install Git (e.g., sudo apt-get install git for Ubuntu).

The hidden abilities of GIT

1

The Curse of updates/patches installation

There will be dark times in your source code committing life- you may even see errors while connecting to GIT. Sometimes the origin for the repository may get reset based on patches updates or windows updates that may ruin your day. Don’t worry, always make sure the configurations are good to go with. 

git remote -v will always help you check if the remote configurations are in place or not. If not you can always set the remote url pointing to origin using the following command:

git remote –set-url origin the-remote-url-here

2

Undo a false GIT ADD

Humans are meant to make mistakes, so do people using GIT. Many-a-times, you might add a file to indexing which you may not want. Undo is the first option that comes to mind. And the GIT community was wise enough to have a managed command ready for us to do that.

 git reset /file/path/here

In case, you made a much bigger mistake, that you even committed the code, don’t worry. The following commands will help you here:

git reset --soft HEAD~1
git reset /file/path/here
git rm /file/path/here
git commit 

3

Amend your commit

In a hurry, it’s easy to forget adding a file to your commit. No worries! The option “amend” has got you covered:

git add /file/path/here
git commit — amend 

4

Delete branch from remote

In case you push something wrongly or in the wrong state on remote, you need to be cautious.

git push origin — delete <branchname> </branchname>

Now go back to your console github/bitbucket, and voila! The branch is no longer in the list. But always remember, any branch you delete on remote is always archived and can be retrieved later. So be cautious before you push something confidential to remote.

5

Unable to pull

Most of the times when you have uncommitted changes, git won’t allow you to pull from remote since the changes may get wrongly overridden. But when you do really meaningful and significant work, you don’t want to revert your changes. But you still want to get the latest pull. 

This is a situation that happens everyday in the life of git user. In case you have been away from this, learn the following command:

git stash

This would stash your existing changes, without the need to commit them and allowing you to take the latest pull and further work on your own changes too. Told you, this is all magical!

6

Another UNDO before it messes up

“Did you just merge the branches that weren't required? How can you do that?” 

Before your boss asks you these questions, make sure you know that ‘revert’ exists!  First, let’s understand how a merge works first. It simply makes the HEAD point to a specific commit. Now you only need to get the HEAD to a better place, where the issues don’t exist.

Run the following command and the HEAD pointer in GIT is back to the right commit you wanted.

git revert HEAD 

Reverting commands have many other customizations available, like you can make HEAD point to a particular commit. But now you know, you can revert things back to a stable state and simply dodge most of the issues.

The above mentioned hacks are frequent occurring scenarios in GIT. Once you add them to your bucket, GIT seems simpler.

Get Started With Engati

We hope this blog has helped you understand GIT a little bit more. 

Try Engati for free today. No credit card needed.

Megha Baweja

Close Icon
Request a Demo!
Get started on Engati with the help of a personalised demo.
This is some text inside of a div block.
This is some text inside of a div block.
This is some text inside of a div block.
This is some text inside of a div block.
*only for sharing demo link on WhatsApp
Thanks for the information.
We will be shortly getting in touch with you.
Oops! something went wrong!
For any query reach out to us on contact@engati.com
Close Icon
Congratulations! Your demo is recorded.

Select an option on how Engati can help you.

I am looking for a conversational AI engagement solution for the web and other channels.

I would like for a conversational AI engagement solution for WhatsApp as the primary channel

I am an e-commerce store with Shopify. I am looking for a conversational AI engagement solution for my business

I am looking to partner with Engati to build conversational AI solutions for other businesses

continue
Finish
Close Icon
You're a step away from building your Al chatbot

How many customers do you expect to engage in a month?

Less Than 2000

2000-5000

More than 5000

Finish
Close Icon
Thanks for the information.

We will be shortly getting in touch with you.

Close Icon

Contact Us

Please fill in your details and we will contact you shortly.

This is some text inside of a div block.
This is some text inside of a div block.
This is some text inside of a div block.
This is some text inside of a div block.
This is some text inside of a div block.
Thanks for the information.
We will be shortly getting in touch with you.
Oops! Looks like there is a problem.
Never mind, drop us a mail at contact@engati.com