Skip to content

Instantly share code, notes, and snippets.

@doleron
Last active June 18, 2020 03:01
Show Gist options
  • Save doleron/db859299ed3e51a6ef5eda3f33c86e3a to your computer and use it in GitHub Desktop.
Save doleron/db859299ed3e51a6ef5eda3f33c86e3a to your computer and use it in GitHub Desktop.
commands to synchronize your fork with original repo

how to synchronize your fork with the original github repo

considering:

The first option is to merge your fork with the original repo

clone your fork if you haven't cloned already

$ git clone https://github.com/youraccount/whatever.git

add original repo as upstream if you haven't done already

git remote add upstream https://github.com/whoever/whatever.git

fetching upstream

git fetch upstream

confirm you are in master branch

git checkout master

merge local

git merge upstream/master

push merge

git push origin master

force reset

Sometimes you prefer to perform a full reset of your fork the following instructions will erase all modifications from your fork and sync it with original repo !!! note that any modification in your fork will be lost !!!

add upstream as before if not yet

git remote add upstream /url/to/original/repo

fetching upstream

git fetch upstream

confirm you are in master branch

git checkout master

hard reseting your local repo from upstream be careful! This command you override everything locally!

git reset --hard upstream/master

pushing local repo to remote fork !!! note that this command will override any change in remote fork with local repo!!!

git push origin master --force 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment