2

Presently I forked a project at Github and adding some new features to it. However, it is really active project and codes are always changing around. How should I keep my forked local copy up to date as I do not lose my changes?

From my search I guess I should use git fetch command and stay away git pull since fetching just takes the commits that are not related to my improvements but pull gets all the changes and merges the changes with my local copy. Am I right that the fetch command is the solution?

erogol
  • 13,156
  • 33
  • 101
  • 155
  • possible duplicate of [Can I update a forked project, on git, to the original/master copy?](http://stackoverflow.com/questions/7297486/can-i-update-a-forked-project-on-git-to-the-original-master-copy) – Sascha Wolf Jan 19 '15 at 14:09

1 Answers1

0

git fetch will update your remote tracking branches, but you won't know if your current branch is still compatible.

It is best to rebase your branch on top of upstream/master, with upstream being a remote referencing the original repo you have cloned.
See "Pull new updates from original Github repository into forked Github repository".

You can combine the two (fetch+rebase) with a git pull --rebase

git checkout yourPRbranch
git pull --rebase upstream master
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Note: this assume that you are doing your "local addition" in a separate branch, not in one already common with the original repo, like '`master`'. – VonC Jan 19 '15 at 13:18