Git

# Clone the Remote Repo (Do not create child directory before)

git clone <clone url>

# Change to the repo

cd <path to repo>

# Create a local branch linked to each remote branch that exists, and fetch and pull them all just in case.

git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done

git fetch --all

git pull --all

# View Branches

git branch

git branch -a

# Checkout a Branch

git checkout BRANCH-NAME

#Create a New Branch

git branch NEW-BRANCH-NAME

git checkout NEW-BRANCH-NAME

or

git checkout -b NEW-BRANCH-NAME

# Rename a Branch

git branch -m OLD-BRANCH-NAME NEW-BRANCH-NAME

# Delete a Branch

git branch -D BRANCH-TO-DELETE

# Compare Branches

git diff FIRST-BRANCH..SECOND-BRANCH

# Track a Remote Branch

git branch --set-upstream-to origin/BRANCH

or

git push -u origin BRANCH

# Prune Remote Branches

git remote prune origin

# Get just 1 branch

git checkout --track origin/<branchname>