Skip to content

Instantly share code, notes, and snippets.

@tommyskott
Last active December 16, 2021 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommyskott/9f4c252d6318cd5936f4b74380abb44b to your computer and use it in GitHub Desktop.
Save tommyskott/9f4c252d6318cd5936f4b74380abb44b to your computer and use it in GitHub Desktop.
Git - Cheat Sheet

Git - Cheat Sheet

A few git commands to get you through the day.

Index

Setup

git config --global user.name "username"
git config --global user.email "you@domain.com"

git config --global user.name
> username

git config --global user.email
> you@domain.com

Remotes

Add, track (set upstream: -u) and push

git remote add origin git@github.com:username/<repo>.git
git push -u origin main

Check your current remotes

git remote -v

Change URL for remote

git remote set-url origin git@github.com:user/repo.git

Branches

Create and checkout new local branch

git checkout -b <branch>

Create new local branch FROM remote and track it (if it exists on remote)

git checkout -b develop origin/develop

Shorter version

git checkout develop

Github for Slack

Get notifications from all branches

/github subscribe owner/repo commits:all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment