Git

General

Remote Repo
git remote -v Manage set of tracked repos
git clone <http> Clone remote repo & Create a local repo into a new dir
git remote add <name> <http> Create a ref named <name> which points to <name>'s repo
git fetch <name> Download changes from <name>'s repo to local repo
git pull <name> Download & Merge changes from <name>'s repo to local repo (= fetch + merge)
git push <name> master Upload a local commit to <name>'s remote repo's master branch
(My own repo: Use "origin")
Branching
git checkout <name> Switch to branch named <name>
git checkout -b <name> Create a local branch named <name> & Switch to branch named <name>
git merge <name> Merge changes made in branch named <name> to current branch
Others
mv <filename> <new filename> Move/Rename file from local only, not repo
git mv <filename> <new filename> Move/Rename file from local and repo
rm <filename> Remove file from local only, not repo
git rm <filename> Remove file from local and repo
git rm —cached Unstage file
git log Display logs
git diff <ci1 hash> <c2 hash> Show changes btw ci1 & ci2
git diff —color <ci1 hash> <c2 hash> Show changes btw ci1 & ci2 with color
git tag -a <tag> -m <message> ??

How to Commit changes?

  1. git add <file.txt>
  2. git commit -m <message>
  3. git push origin master

Branching

Create
git checkout -b <name>
Merge
git checkout master
git merge <name>