Skip to content

Instantly share code, notes, and snippets.

@craigpearson
Created February 6, 2019 00:41
Show Gist options
  • Save craigpearson/3469a7c842301e4d2f89b72e5dfe57f3 to your computer and use it in GitHub Desktop.
Save craigpearson/3469a7c842301e4d2f89b72e5dfe57f3 to your computer and use it in GitHub Desktop.
Git Cheatsheet

Git Cheatsheet

Cloning a repo

# Clone repo to current folder
git clone https://github.com/USERNAME/REPOSITORY.git

# Clone repo to specified folder
git clone https://github.com/USERNAME/REPOSITORY.git specified-folder

# Clone the contents of the repo to current folder
git clone https://github.com/USERNAME/REPOSITORY.git .

# Clone repo with history truncated to specified commts
git clone --depth=1 git@github.com:USERNAME/REPOSITORY.git

Working with a fork

# add the original repository as remote repository called "upstream"
git remote add upstream https://github.com/USERNAME/REPOSITORY.git

# fetch all changes from the upstream repository
git fetch upstream

# switch to the master branch of your fork
git checkout master

# merge changes from the upstream repository into your fork
git merge upstream/master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment