# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches
git fetch upstream
# Make sure that you're on your master branch:
git checkout master
# Rewrite your master branch so that any commits of yours that# aren't already in upstream/master are replayed on top of that# other branch:
git rebase upstream/master
$ git branch -va# List all local and remote-tracking branches* master a422352 My local commitremotes/origin/HEAD -> origin/masterremotes/origin/master a422352 My local commitremotes/upstream/master 5fdff0f Some upstream commit
$ cd project-name
$ git remote add upstream https://github.com/user-name/project-name.git# Adding the upstream -> the main repo with which you wanna sync
$ git remote -v # you will see the upstream here
$ git checkout master # see if you are already on master branch
$ git fetch upstream