@dimmus

Git - Sync fork

  1. List the current remotes
git remote -v
  1. Add the remote, call it “upstream”
git remote add upstream https://git.enlightenment.org/enlightenment/efl.git
  1. Fetch all the branches of that remote into remote-tracking branches
git fetch upstream
  1. Make sure that you’re on your master branch:
git checkout master
  1. Stash the changes of your “master” branch:
git stash
  1. 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

At this stage you check that commits what will be merged by typing git status. If you don’t want to rewrite the history of your master branch, (for example because other people may have cloned it) then you should replace the last command with git merge upstream/master.

Instead of the rebase command, you can use the following:

git merge --no-ff upstream/master 

This way your commits aren’t on top anymore.

  1. If you’ve rebased your branch onto upstream/master you may need to force the push in order to push it to your own forked repository on GitHub. You’d do that with:
git push -f origin master

You only need to use the -f the first time after you’ve rebased.

  1. Get back your stashed changes (if any)
git stash pop