- Source: Git Cheat Sheet
- create new repository =
git init
- clone local repository =
git init
- clone remote repository =
git clone username@host:/path/to/repository
- add changes to INDEX =
git add <filename>
- add all changes to INDEX =
git add*
- remove/delete =
git rm <filename>
- commit changes =
git commit -m *Commit message*
- push changes to remote repo =
git push origin master
- connect local to remote repo =
git remote add origin <server>
- update local with remote repo =
git pull
- Create new branch =
git checkout -b <branch>
- Switch to master branch =
git checkout master
- Delete branch =
git branch -d <branch>
- Push branch to remote repo =
git branch -d <branch>
- Merge changes from another branch =
git merge <branch>
- View changes between two branches =
git diff <source_branch> <target_branch>
e.g. git diff feature_x feature_y
- Create tag =
git <tag> <commit ID>
e.g git tag 1.o.o 1b2e1d63ff - _Get commit IDs =
git log
- Replace working copy with latest from HEAD =
git checkout --<filename>