Skip to content

Instantly share code, notes, and snippets.

@meiqimichelle
Last active February 4, 2020 23:37
Show Gist options
  • Save meiqimichelle/c2b8b82a003ebe7824c67c6685b2f144 to your computer and use it in GitHub Desktop.
Save meiqimichelle/c2b8b82a003ebe7824c67c6685b2f144 to your computer and use it in GitHub Desktop.
git cheatsheet

Keep forked repo in sync with upstream

  • Fork repo
  • Create feature branch, do some work
  • PR upstream from feature branch
  • Work is accepted/merged into upstream master
  • Delete feature branch (Can do this via GH interface on upstream PR. This will also delete the branch in your repo.)
  • Delete local branch because you like to keep things organized and clean, and this feature branch is dead to you.
  • Rebase your repo to get everything in the same place by doing:

git fetch upstream

git rebase upstream/master

Show colorful visual graph history

git log --graph --oneline --all

Delete origin branch from local

  • Basically, you're pushing an empty branch over an existing one:

git push origin :feature-branch

ie, git push origin [EMPTY HOLE WHERE INFO COULD BE]:feature-branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment