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

Time:10-29

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.

CodePudding user response:

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.

  •  Tags:  
  • git
  • Related