Common git commands

I use git as my source control system. Here are some of the most common git commands in no particular order.

  • Check Out a git Repository git clone /path/to/repository
  • Add files to commit git add
  • Commit files to git git commit -m “Commit message”
  • Push changes to server git push origin master
  • Show status git status
  • Create new branch git checkout -b
  • Switch to a branch git checkout
  • Get remote changes git pull
  • Merge a different branch into the current one git merge
  • View merge conflicts git diff
  • Temporarily stash uncommitted changes git stash
  • Undo a commit git reset –hard
  • Show details about a commit git show
  • Show version history of current branch git log
  • Gets all remote branches git fetch origin

Most of the time I use the git extensions tools to do my git work, but there are times when only the command line will do.

Comments

comments powered by Disqus