Top 10 Git commands with example

By Aryan Maurya / May 12, 2022

Top 10 Git commands listed here:

  • git config
    • git config -global user.name “[name]”
    • git config -global user.email “[email]”
  • git clone
    • git clone [url]
  • git add
    • git add [file]
    • git add *
  • git commit
    • git commit -m “commit message text”
    • git commit -am “commit message text” ( add & commit file with this command )
  • git status
    • git status ( This command lists all the files that have to be committed )
  • git stash
    • git stash ( This command discards all changes )
  • git branch
    • git branch ( This command shows all local branches )
    • git branch -a ( This command shows all branches )
  • git fetch
    • git fetch ( This command fetches all updates )
  • git checkout
    • git checkout [branch-name]
    • git checkout -b [branch-name] ( new branch created and checkout )
  • git merge
    • git merge [branch-name]
    • example –
      • git checkout [main-branch]
      • git merge [branch-name]
  • git push
    • git push ( This command sends the committed changes of the working branch to your remote repository )
  • git pull
    • git pull ( This command fetches and merges changes on the remote server to your working directory )
  • git show
    • git show ( This command shows the content changes of specified files )
  • git log
    • git log ( This command is used to list the version history for the current branch )
May I Help You?