Top 8 Common Git Commands Used by Developers
By Karthi | July 31, 2026
Git is one of the most essential tools in modern software development, and understanding Common Git Commands is a must for anyone working in a team or contributing to real-world projects. From tracking changes to managing branches and collaborating efficiently, these commands form the backbone of everyday development workflows.
In this article, we’ll explore the Top 8 Common Git Commands Used by Developers that you’re most likely to use on a daily basis. Each command will be explained with simple examples to help you understand how and when to use them effectively in real projects.
Before learning the most Common Git Commands, it’s important to understand what Git is and why developers rely on it for version control.
What is Git?
Git is a Version Control System (VCS) created by Linus Torvalds, the developer of Linux, in 2005. Although it can track changes in all kinds of files, it is primarily used for software development.
So, what are the advantages of using Git? Let’s take a look:
- Track all files: Developers can easily navigate development files, revert to previous versions, and detect changes when releasing updates.
- Collaborate better: Changes made by multiple developers can be combined smoothly.
- Work efficiently: You can work on multiple features at the same time by using branches, which we’ll cover later in this article.
- Cross-platform: It is compatible with Windows, macOS, and Linux for installation.
If you work solo, you can keep the entire database on your local device. However, when collaborating with others, the project should be stored and shared via a remote repository, usually hosted on platforms like Github.
As Git is a distributed version control system, users are able to clone the master repository onto their local machine and make modifications even without an internet connection.
Conversely, users of centralized VCS like SVN or CVS need to connect to the master repository to make changes. Therefore, Git is a better option if you seek more flexibility in your workflow.
Top 8 Common Git Commands:
1. Git Workflow:
Each local repository consists of three main parts: the working directory, the staging area, and the Git repository. You should Understanding the Git Workflow tis essential because many Common Git Commands interact directly with these areas during day-to-day development.
The working directory holds the files you plan to modify, and once you do, changes are temporarily saved (indexed) in the staging area.
In the second area, you can continue to make further modifications to your files. When ready, choose the changes you wish to commit and save permanently.
Your Git repository contains your commits, which you can push to the master repository to enable other developers to review your changes. Keep in mind that Git needs a username associated with your commits.
To do this, set up your identity using the following command:
git config –global user.name “name”
git config –global user.email “email address”
Thanks to this small detail, your teammates can easily see who made the changes.
2. Getting Git Repositories:
One of the first Common Git Commands developers learn is git init, which creates a new repository. Another frequently used command is git clone, which allows you to copy an existing repository to your local machine.
This section of the tutorial explains how to either initialise a local directory as a git repository or clone an existing one, using two different approaches. Getting Git Repository in first place is to know the Git Basics.
To apply the first method, execute the pwd command to determine your current directory. This command outputs the full path to your present local folder.
If you’re not in your project folder, use this command to change to it:
cd <path of directory>
Navigate to the correct directory, then run git init to allow Git to start tracking file changes.
git init
Running git init creates a .git subdirectory within the local folder that stores the snapshot of your changes.
If you’re working on a project with others, you can clone the remote repository to your local machine and edit the files locally.
git clone <address of remote repository>
3. Indexing and Committing Changes:
Among the most important Common Git Commands are git add, git status, and git commit. These commands help developers track modifications and save meaningful checkpoints in their projects.
If you’ve made changes to a file named test.html, you need to stage it before committing by using this command:
git add test.html
At this point, you can still make some adjustments if needed. Then, use this command to verify that all your changes are staged.
git status
Then, commit the file:
git commit –m “Message to go with the commit”
Next, execute the git status command again. If it shows nothing to commit, it means all changes have been saved.
If your commit message has errors, don’t worry! You can use this command to revise the latest commit message.
git commit –amend -m “updated commit message”
After saving and exiting, the message will update.
4. Viewing Logs:
The git log command is one of the Common Git Commands used to review project history and identify previous changes made by team members.
Use the git log command to review the commit history. It displays a list of commits with details like the author, date, commit ID (hash), and the message.
Use the following method to fetch commits from a particular user:
git log –author =Smith
5. Tagging Commits:
When developing a software product, at some stage you’ll commit changes and prepare for an update release. It’s recommended to tag that commit for easy identification of the release afterwards.
Here’s the command to do so:
git tag -a<version-number>
By default, ‘git tag’ targets the latest commit. To tag an earlier commit, specify the commit ID (hash) after the version number.
git tag -a<version-number> <commit unique ID>
You can obtain the commit ID from the output of the git log command. Copy only the first eight to ten characters; there’s no need to include the full hash.
To do a successful tagging commits, get basic of tagging.
6. Working with Git Branches
This section of the tutorial explains how to handle git branches.
If you need to fix bugs or add new features, consider using branches to keep changes isolated from the main development line (master branch).
After confirming the project in the branch is working, it will be merged into the master branch. This step ensures the master branch incorporates these updates. We will cover the merging process more thoroughly in the next section.
To see your local repository’s branches, use this command:
git branch
To create a new branch, just specify its name.
git branch <branch name>
Although you have successfully created a new branch, you are still on the master branch. To start editing the new branch, you need to switch to it.
git checkout <branch name>
Don’t forget to add and commit the changes.
It is common to delete outdated branches that have already been merged and are no longer active.
git branch -d <branch name>
However, the command mentioned above prevents you from deleting unmerged branches. Git issues a warning because, if the branch isn’t merged, the master branch won’t incorporate the changes you made there.
Use this command to forcibly delete branches that haven’t been merged.
git branch -D <branch name>
7. Merging and Pushing the Branches
Merging involves integrating changes from one branch into another. After finishing a new feature in a branch, you should merge it into the master branch to include those updates.
Begin by switching to the master branch with ‘git checkout’, then execute ‘git merge’ to combine changes.
git merge <branch name>
Once you’ve committed your changes and are prepared to share them with your team, it’s time to push your commits to the remote repository.
Before pushing the commits, verify that your command line is pointed to the correct remote repository by using this command:
git remote -v
If it is not pointing to the correct address, you need to update it.
git remote set-url origin <remote repository address>
You’re now ready to upload the commits to the remote repository.
git push origin master
That’s all! Now you can see the commits from your local repository reflected in the remote one.
8. Downloading Remote Branches
Remote branches are the branches kept in your remote repositories. In a collaborative project, these remote branches reflect the work of your colleagues.
Imagine cloning a remote repository while working on a local branch. At the same time, your teammates have pushed their own branches and updated the remote repository.
Now, you need to update your working directory to incorporate your teammates’ recent changes. You can do this with either git pull or git fetch, but note that these commands have different effects.
`git fetch` retrieves all remote branches without altering your local repository, ensuring a safe way to update your working directory.
On the other hand, ‘git pull’ retrieves the remote repository content and merges it into your current branch, which may occasionally cause conflicts.
NOTE: You can also Connect Github to cPanel through Git Version Control option.
Git assists in organising and managing your software development. Whether solo or in a team, it offers support! You can easily initiate new projects, clone existing ones, build new features with branches, and collaborate by sharing your work.
