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.
8 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