Git: How do I merge the remote branch of another developer's with my master branch?


I am currently a graduate student trying to do some research using a large software project that the group I am a part of is developing. However, the specific piece of the project that I need was developed by another student who has since graduated, and has yet to merge his code with the main codebase.

I really need to get my hands on this code, but it’s been several weeks since I talked to him, and he hasn’t initiated a merge request yet. Is there a way for me to remotely merge his branch with my master branch?

So far, I have tried to bring this up during a group meeting. I’m not sure if I communicated the situation in the most exact or effective way because I was trying to be diplomatic, but the impression I was left with is there’s a way for me to get a hold of the changes he’s made without needing to clone the main codebase after he’s merged with it.


Add their repo as a new remote. Fetch it. Merge their branch.

There might be a way to do this on Github, but it’s easy to do manually.

Add them to your local repository as a new remote repository. git remote add <name> <url> You can name it whatever you want, perhaps after their username.

Fetch it. git fetch <name>. This won’t affect your work at all. All of their branches will be prefixed with their remote name; their main branch will be <name>/main.

And merge it like any other branch. Alternatively, if you just need certain commits, you can cherry pick them.

Since the branch is a little old, you might want to first update it. Make a new local branch from their remote branch: git branch <branch> <name>/<branch>. Then merge any updates into that new branch. Test it. Do any necessary fixes. Then merge the branch.

Answered By – Schwern

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published