28

Let's say a repository from which I clone (and only read-only for me) is:

git@github.com:secret_project/dev.git  branch: dev

I forked project and URL:

git@github.com:secret_user/Dde.git

(Which I have full access to: read+write)

But someone updated git@github.com:secret_project/dev.git from another forked version.

Let's say file changed on

git@github.com:secret_project/dev.git  (test.txt)
content:
hi!

But my forked project has test.txt file with content:

hi

So how do I update the forked project locally and in my repository?

Which commands should I use? And please make an example with my showed repositories...

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ZeroSuf3r
  • 1,961
  • 8
  • 25
  • 36
  • possible duplicate of [How to update GitHub forked repository?](http://stackoverflow.com/questions/7244321/how-to-update-github-forked-repository) – kapa Mar 05 '14 at 12:27
  • 2
    @kapa : `How to update GitHub forked repository?` is newer than this post ... – mpromonet Jan 17 '16 at 16:27

2 Answers2

24

You should add the remote address for the original repository 'upstream' to your local repository (which is a clone of your Dde.git fork):

git remote add upstream git://github.com/secret_project/dev.git # public read-only URL

That will allow you to pull 'upstream' into your own branch (merging and resolving any merge conflict in test.txt).
Then you will push your local branch to your Dde GitHub repository.

See GitHub help page: "Working with remotes" for more details.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    If you name it `upstream` — so, type `git remote add upstream` instead of `git remote add dev` — you'll be able to follow [GitHub's documentation "Syncing a fork"](https://help.github.com/articles/syncing-a-fork/). You'll also stay clearer on which development is yours and which was done, well, upstream. – fureigh Nov 14 '16 at 08:17
  • 1
    @fureigh Thank you. I usually do that in later answers (like http://stackoverflow.com/a/9257901/6309), but I apparently did not have that practice 5+ years ago. I have edited the answer accordingly. – VonC Nov 14 '16 at 08:19
  • Thanks for updating the answer! (Also, I notice in retrospect that my tone could've read as snarky — it certainly wasn't intended that way, so if it came off that way, my apologies.) – fureigh Nov 30 '16 at 00:20
1

Just send out a pull request from your repository's GitHub page to your Parent repository. Then pull the changes in your local forked repo and commit and send a fresh pull request.

goodmayhem
  • 3,364
  • 4
  • 16
  • 17