Top 10 Most important git Commands

In this article, we learn some most important git commands that every developer should know if their organization is using GitHub.


Most important git Commands


Most important git commands

Here is the list of some most important git commands which can be used to maintain the code base-


1. git init

This command initializes a new Git repository in the current directory.

Example –

$ git init


2. git clone

This command creates a copy of a remote repository, in this case, a repository hosted on GitHub on your local machine.


$ git clone


3. git pull

The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. It is a combination of git fetch and git merge commands.


$ git pull origin main


4. git status

This command displays the current status of the repository, including modified and untracked files.

Example –

$ git status


5. git add

This command stage changes to the specified files (file1.txt and file2.txt) to be committed.

Example –

$ git add file1.txt file2.txt


6. git commit

This command creates a new commit with the staged changes and the specified commit message.

Example –

$ git commit -m "Commit message"


7. git log

This command displays a log of previous commits.

Example –

$ git log


8. git diff

This command shows the differences between the working directory and the last commit for the specified file (file1.txt).

Example –

$ git diff file1.txt


9. git branch

This command lists all branches in the repo and highlights the current branch.

Example –

$ git branch


10. git push

This command pushes the local commits on the “mybranch” to the remote repository “origin”

Example –

$ git push origin mybranch


Also, it’s important to use Git commands and options carefully to make sure you are doing the right thing and that you don’t end up losing code changes or data. A good practice is to use “git help commandname” to learn more about the command and its options before using it.



I hope now you have some insight into the git command these commands will make your life easy while using GitHub for code management.

Posted in git