How to merge a branch from one remote to the origin/master

86 views Asked by At

Let's say I have a repo X on GitHub , and I'm interested in the branch DEV. I also have a repo Y on Codeplex.
What I'd like to do is first adding X repo on GitHub as a remote of repo Y; then, I want to be able to fetch the content of X/DEV and merge it into Y's origin/master branch.

I'm a Git newbie, so I'd like to read a step by step explanation. I tried to do it myself, but I ended up pushing the content of X/DEV to X/master by mistake...

1

There are 1 answers

1
JJD On BEST ANSWER

If you want to merge repositories they should share a common history of commits. That means their hash should be identical for at least some commits in the past. This is not a technical requirement. You can merge projects of different context but think about a reason first.

To merge repositories that are located on different servers such as GitHub and Codeplex you should first clone them to your machine. There you can add so called remotes to one repository.

$ cd folder/of/your/repository
$ git remote add some-alias git@path-to-remote-repository

This gives you access to the commits of the other repository aka. remote. However, you cannot publish this "connection" information onto GitHub or Codeplex.

Another option is to import the repository from Codeplex to GitHub using the GitHub Importer.