First, you want to make sure that your upstream is setup. Here origin
is your fork and upstream
is the forked repo.
$ git remote -v
origin https://github.com/YakDriver/watchmaker.git (fetch)
origin https://github.com/YakDriver/watchmaker.git (push)
upstream https://github.com/plus3it/watchmaker.git (fetch)
upstream https://github.com/plus3it/watchmaker.git (push)
If you don't have the main repo, then add the remote (i.e., upstream) repo.
You can call it anything but convention says that the repo you own (i.e., your fork) is the origin
while the main repo (i.e., the one you want to submit a PR to) is upstream
.
$ git remote add upstream https://github.com/user/repo.git
Now with upstream
setup, you can sync the two when changes happen on the upstream repo that
you want to bring back to your repo.
NOTE: There are two ways to do this. One is a hard reset. You will lose all changes to origin. This might be good if you messed up your fork and want to have a reset. I've also found this handy when my origin gets hosed up.
The HARD Reset
develop
here is the name of the branch you want to reset. The branch must exist in both origin
and upstream
.
$ git fetch --all
$ git checkout develop
$ git reset --hard upstream/develop
$ git push -f
The SOFT Reset
This will apply any commits that have been applied to upstream
and apply them to your repo.
develop
is the name of the branch you want to reset. The branch must exist in both origin
and upstream
.
$ git checkout develop
$ git pull upstream develop
$ git push