23

I forked a popular github project to make certain minor adjustments for my needs. However I want to keep my fork up to date with the master repo. What I did initially was fork via the github ui, then pushed my changes directly to this fork from my dev env. I'm not entirely convinced I should have done this as I think it makes pulling updates from the master repo difficult.

What's the recommended method for maintaining a fork in this fashion and what do I have to change about my current setup?

user1561108
  • 2,666
  • 9
  • 44
  • 69
  • 3
    I'd recommend doing rebase rather than merge (which is step two of pull). Rebase will always try to reapply your changes on top if the latest code from the forked repo and will make it easier to revise your modifications if necessary. – sudarkoff Jan 12 '13 at 05:07

1 Answers1

13

You can configure to remote repositories to use in git. In the project cloned from your fork, type the following comand: git remote add name url where name is a alias to a url that represents the master repo.

With that, to bring the new updates from the master repo, just type: git pull name master. To send the changes to your fork repo: git push origin master.

William Seiti Mizuta
  • 7,669
  • 3
  • 31
  • 23
  • 3
    I was prepared for some mind boggling git-fu but this actually made sense first time. Relieved thanks! – user1561108 Jan 12 '13 at 01:36
  • 4
    I generally keep my forked development on a uniquely-named branch. That way branches like "master" can remain direct copies of the upstream project and there's less confusion. – Steve Clay Aug 09 '14 at 00:53