34

A few weeks ago i forked a public project on GitHub. Today, I wish to try some stuff on it BUT i want to make sure the copy I use is the most recent.

Can I update my fork, first?

And what happens if there's changes to the fork AFTER i've started my changes. Can i update my fork again, while leaving my changes in there (ie. merge, if needs be?)

manojlds
  • 290,304
  • 63
  • 469
  • 417
Pure.Krome
  • 84,693
  • 113
  • 396
  • 647

1 Answers1

45

Yeah you can pull the changes from the original repo into your fork. Add a remote to it ( since origin will be your fork ) and pull.

This from GitHub help:

First up, add a remote to the original repo.

Help here: http://help.github.com/remotes/

Then you can pull in updates to the original repo. Quote from http://help.github.com/fork-a-repo/

Pull in upstream changes

If the original repo you forked your project from gets updated, you can add those updates to your fork by running the following code:

$ git fetch upstream

$ git merge upstream/master

All these are for doing from command line.

Below are instructions for TortoiseGit:

Right click over your project -> TortoiseGit -> Settings -> Remote.

Add the remote details here:

enter image description here

Now, right-click -> TortoiseGit -> Pull.

You will be presented with a dialog to choose the remote ( you should be able to see the remote you added in previous step). Choose it and pull.

enter image description here

Michiel Pater
  • 22,377
  • 5
  • 43
  • 57
manojlds
  • 290,304
  • 63
  • 469
  • 417
  • 1
    Whoa - that makes no sense. Ok.. `rebase`.. I'm using `TortoiseGit` .. do I do this `rebase` thing in the `Git` website or on my filesystem where my fork exists? – Pure.Krome Sep 04 '11 at 05:20
  • @Pure.Krome - You do this on your local (filesytem) clone. I have updated my answer to make "more sense" – manojlds Sep 04 '11 at 05:45
  • Awesomesauce - works :) The only thing I needed to figure out was after the first screen shot, i needed to add in a remote name and the url of the source repo i forked from (which wasn't hard to figure out). I called the remote `upstream` like the git docs and your screenie :) Seems to be great! – Pure.Krome Sep 04 '11 at 13:04