git init
Create an empty git repository or reinitialize an existing one
git config
git clone
Example: git clone git@github.com:user/test.git
git add
Example: git add .
git rm
Removes files from your index and your working directory so they will not be tracked.
Example: git rm filename.txt
git commit
Examples: git commit -m ‘adding changes’
git commit -a -m ‘commit all changes. Its same as git add and git commit’
git status
git branch
Example: git branch -a
git checkout
Checkout a branch or paths to the working tree
Example: git checkout filename.txt
git merge
git reset
Resets your index and working directory to last commit.
Example: git reset –hard HEAD
git stash
Temporarily saves changes so that you don’t want to commit immediately. You can apply the changes later.
Example: git stash
To restore stash back type “git stash apply”
git tag
Tags a specific commit with a simple, human readable handle that never moves.
Example: git tag -a v1.0 -m ‘version 1.0 tag’
git fetch
Fetch objects and refs from another repository
Example: git fetch origin
git pull
Fetch objects from remote repository and merg it with local repository.
This is same as git fetch and the git merge commands one by one.
Example: git pull origin
git push
Push all the changes to remote repository.
Example: git push origin master
git remote
Shows all the remote versions of your repository.
Example: git remote
git log
Shows a list of latst commits.
Example: git log
git show
git grep
Lets you search through your trees of content.
Example: git grep “sendmail” — *.php
git diff
Show changes between commits, commit and working tree, etc.