$ git init [project-name]
Creates a new local repository with the specified name
$ git clone https://github.com/[organization]/[repository].git
Clones the repo into a new filder named ‘repository’
$ git status
Lists all new or modified files to be committed
$ git --version
Show the git version.
$ git add [file]
Snapshots the file in preparation for versioning
$ git commit -m "[descriptive message]"
Records file snapshots permanently in version history
$ git commit -am “[descriptive message]”
Flag ‘a’ is used to directly commit a file without staging
$ git tag “[tag name]”
A tag reference is created which points to the current commit.
$ git branch
Lists all local branches in the current repository
$ git branch [branch-name]
Creates a new branch
$ git checkout [branch-name]
Switches to the specified branch and updates the working directory
$ git shortlog -ns
Most common committers
$ git log --oneline
Lists version history for the current branch
$ git log --oneline --all
Shows complete log irrespective of current checked out commit
$ git log --reverse
Reverse log
$ git tag -n
List all tags along with messages
$ git branch -a
List all branches
$ git branch -r
Show all remote branches
$ git log tag1..tag2
Show log between two tags
$ git config --global user.name “Kamal Banga”
Set username.
$ git config --global user.email “kamal@sigmoidanalytics.com”
Set email.
$ git config --list
List all settings.