Skip to content

Instantly share code, notes, and snippets.

@uzluisf
Created December 19, 2020 14:43
Show Gist options
  • Save uzluisf/9f40117ea79ac269a67d0db1337fef27 to your computer and use it in GitHub Desktop.
Save uzluisf/9f40117ea79ac269a67d0db1337fef27 to your computer and use it in GitHub Desktop.
Git Commands I Forget Too Often

Keeping fork up to date

git clone /url/to/original/repo                     # clone fork
git remote add upstream /url/to/original/repo       # add remote from original repo
git fetch upstream                                  # fetch content from upstream (i.e., repo forked from)
git pull upstream master                            # fetch and merge upstream into master

Clean up fork and restart from upstream

E.g., send a PR from master, PR was closed, and now want to restart from upstream's latest changes

git remote add upstream /url/to/original/repo       # no needed if set already
git fetch upstream
git checkout master
git reset --hard upstream/master  
git push origin master --force 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment