Feather Blog has made some great progress recently and when looking to update my fork I found myself staring at my repo not sure what to do. My wonderful Github didn’t give me a one-click way to pull updates from the original repository (or any other fork for that matter). I’ll demonstrate how to do this with my fork of Feather. I’ll assume you already have a locally copy of a repo with everything committed and up-to-date.
First you need to add a remote branch to your repository that points to the original repo you forked from.
git remote add --track master mleung git://github.com/mleung/feather.git
You will want to replace ‘master’ with the branch you want to track in the remote repo. In most cases this will be master, although you could replace it with edge or any other branch. You should also replace ‘mleung’ is what you the remote will be called.
To verify the remote repository was added run
git remote
You should see the new remote repo, in this case named ‘mleung’, along with any other remote repositories you may have previously added.
Now we can fetch all the changes from mleung’s code base.
git fetch mleung
This will create a new remote branch called ‘mleung/master’. Now we are ready to merge the code from the remote repository.
git merge mleung/master
That’s it. Remember, this process isn’t limited only to the original repository. Feel free to add remote branches for other user’s forks or even from repositories outside Github.
15 Comments
Cheers for this. Git newb myself and this wasn’t that obvious
Thanks for this. I just wanted to add, that instead of doing `git fetch mleung` then `git merge mleung/master`, you can do it in one step with `git pull mleung master`.
Before your post I was doing it the old fashioned way, e.g. `git pull git://github.com/mleung/feather.git master`. You just saved me a bunch keystrokes!
Thumbs up!
Thanks
Thanks for the info. I just started using git this week and your post helped out a lot!
Wow buddy, thats precisely what I was looking for. Thank u very much for the info!!
I get “fatal: Not a git repository (or any of the parent directories): .git” when I try to run “git remote add –track master mleung git://github.com/mleung/feather.git”. Why?
@Erik Nord – I think you need to change your CWD to the git repo that you want to add the remote repo to – that error usually indicates that you aren’t (locally) in a git repository.
Thanks for the tip, worked great
хорошо
нирвана!
So using GitHub I would typically:
1. fork a repo
2. clone my fork to create a local repo
3. add ‘upstream’ remote, pointing to original repo
Now when upstream changes happen I would:
4. fetch from upstream into local repo
5. merge upstream changes
But what now? my fork on github is still not updated. My local repo contains changes fetched from upstream, but my fork on GH does not. If I try to push master to origin I just get the message ‘Everything up-to-date’.
???
@Joe
You have to push to remote
on the github.com site you can go to your fork of the project, click the network tab, and then click fork queue. you can pull/merge changes from the parent master here. This also allows you to cherry pick changes.
@Joe
4. git fetch upstream
5. git merge upstream/master
6. git push
7. refresh your github fork’s web page and do the happy muppet dance
$ git fetch test
fatal: Unable to look up https (port ) (nodename nor servname provided, or not known)
you wirte is just the same on the github.com, but I question is: it is only sync local repo ,but not the remote repo, I think if I make a new clone for my remote repo, it would old. dose it ?
6 Trackbacks
[...] That’s it. Remember, this process isn’t limited only to the original repository. Feel free to add remote branches for other user’s forks or even from repositories outside Github. via bradlyfeeley.com [...]
[...] Bradly Feeley » Update a Github Fork from the Original Repo. This was written by Daniel Drzimotta. Posted on Friday, October 1, 2010, at 9:33 am. Filed under Uncategorized. Tagged fork, git, github, merge. Bookmark the permalink. Follow comments here with the RSS feed. Post a comment or leave a trackback. [...]
[...] Bradly Feeley » Update a Github Fork from the Original Repo. This was written by Daniel Drzimotta. Posted on Wednesday, November 10, 2010, at 1:33 pm. Filed under Uncategorized. Tagged forking, git, github, merging. Bookmark the permalink. Follow comments here with the RSS feed. Post a comment or leave a trackback. [...]
[...] 最新的master版本(这篇文章在我不熟悉git的时候帮了我不少忙),又在他已经写好的代码上学习了google [...]
[...] Here is the link (it was a blog i found on the net): http://bradlyfeeley.com/2008/09/03/update-a-github-fork-from-the-original-repo/ [...]
[...] to update these forks against their master and the Google has provided a very concise blog post here(http://bradlyfeeley.com/2008/09/03/update-a-github-fork-from-the-original-repo/). Kudo’s to Bradly Feeley. Posted by David at 3:20 pm [...]