Git

Generate a new SSH key

ssh-keygen -t rsa -b 4096 -C "[email protected]"

pbcopy < ~/.ssh/id_rsa.pub

Basics

# Show where git configs get defined
git config --show-origin -l

# Set username and email (global - for all repos)
git config --global user.name "Rynaard Burger"
git config --global user.email "[email protected]"

# Set username and email (global - for current repo)
git config user.name "Rynaard Burger"
git config user.email "[email protected]"

# Initialize a new repository
git init

# Add a remote
git remote add origin [email protected]:rynaardb/code.git

# Get log
git log

# Get status
git status

# Create new branch
git checkout -b

# New branch without git history & files
git checkout --orphan

# Checkout branch
git checkout <branch>

# List remote branches
git branch -a

# Staging files
git add . 
git add FILENAME

# Pushing changes
git push 
git push origin <branch>

# Fetching changes
git fetch
git fetch origin <branch>

# Pulling changes
git pull 
git pull origin <branch>

# Pull from master when working with forks:
git pull upstream <branch>

Commit

Stashing

Reset

Delete

Tags

Force

Cherry Picking

Create a diff patch

Quickly pull down PRs

Misc

Last updated