Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 2.02 KB

Git CheatSheet.md

File metadata and controls

45 lines (35 loc) · 2.02 KB

Git Cheat Sheet

Create & Clone

  • create new repository = git init
  • clone local repository = git init
  • clone remote repository = git clone username@host:/path/to/repository

Add & Remove

  • add changes to INDEX = git add <filename>
  • add all changes to INDEX = git add*
  • remove/delete = git rm <filename>

Commit & Synchronize

  • 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

Branches

  • 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

  • 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

Tagging

  • Create tag = git <tag> <commit ID> e.g git tag 1.o.o 1b2e1d63ff
  • _Get commit IDs = git log

Restore

  • Replace working copy with latest from HEAD = git checkout --<filename>

Resources