Linux

List of Useful Git Commands

List of Useful Git Commands

In this tutorial, I will list out some useful git commands list. Now a days, GIT is very useful to manage your project in one place.

So, I am posting here some importance GIT commands list. Bookmark this blog in your browser đŸ™‚

You may also like this :

GIT Commands :

1. git config :

This command is useful for set author name and email address respectively to be used with your commits.

It will use for set git config user name :

git config --global user.name "Your Name"

It will use for set git config user email :

git config --global user.email "Your Email"

To get git config user name :

git config --global user.name

To get git config user email :

git config --global user.email

2. git clone :

This command is useful to clone a repository from an existing URL.

git clone <Your Git Clone URL>

3. git add :

This command is useful to add files into specific branch.

If you want to add all files using git then, you can use below commands :

4. git commit :

This command is useful to commit file changes after add files into specific branch.

git commit -m "Your commit description"

5. git diff :

This command is useful to check diff of files

If you want to check diff between two branches then, you can execute below commands :

git diff <first branch name> <second branch name>

6. git branch :

This command is useful for display current branch.

git branch -d <branch-name> : To delete branch in git.

git branch -a : List all remote branches.

git branch -m <oldname> <newname> : Rename a branch

git branch -m <newname> : Rename the current branch

7. git reset :

This command is useful for reset file changes.

This command is useful for reset commit changes.

8. git status :

This command lists all the files that have to be committed and modified.

9. git log :

This command is useful to list the version history for the current branch.

10. git show :

This command is useful to shows the metadata and content changes of the specified commit.

git show <commit id> –name-only : It will return file names only by commit id in git.

11. git checkout :

This command is useful to switch from one branch to another.

git checkout <branch name>

git checkout -b <branch name> : This command creates a new branch and also switches to it.

12. git merge :

This command merges the specified branch’s commit changes into the current branch.

13. git push :

This command sends the branch commits to your remote repository.

git push <variable name> <branch name>

For ex : git push origin staging

14. git pull :

This command fetches and merges changes on the remote server to your working directory.

git pull <variable name> <branch name>

For ex : git pull origin staging

That’s it !!

I hope this blog is helpful to your for use GIT commands. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with proper solution.

Keep liking and sharing !!

Tagged ,