Assuming that you forked a repository and cloned it on your local machine

  1. To list the current remote repository for your fork:
$ git remote -v
origin (fetch)
origin (push)
  1. Specify a new remote upstream repository that will be synced with the fork
$ git remote add upstream
  1. To verify the upstream repo
$ git remote -v
origin (fetch)
origin (push)
upstream (fetch)
upstream (push)
  1. To sync local master with upstream master
git pull --rebase upstream master
  1. To push changes to remote forked repository
git push -f origin master
  1. Sync working branch with
git checkout branch_name
git rebase master