user5417542
user5417542

Reputation: 3376

Merge commits of one repo to another one

I know it's an unfortunate setup, but I have two Repos:

1.) Repo A is the base Repo, which is a project used as the base for other projects.

2.) Repo B, from which I forked Repo A and made modifications.

In the meantime Repo A gets some new features and updates.

Now I want to update Repo B to take over the new changes and updates of Repo A, but keep my modifications.

I could now create a new Branch from Repo B with the forked newest version of Repo A. And then I could manually copy paste my modifications to it.

But this is of course error sensitive and takes time. Is there a way to first identify my commits and modifications, I have made to Repo B, and let Git merge the changes to my newly forked Branch based on Repo A?

I guess cherry picking is a bit tedious, because it would go through all commits, even though, they aren't the latest. So maybe one diff, which shows the difference between Repo B and the Repo A to the time I forked it, and make it possible to merge this diff?

Upvotes: 2

Views: 961

Answers (1)

Simon
Simon

Reputation: 379

You can have multiple remote repositories for each local repository. What I would do is go your local checkout of Repo B, and add remote Repo A as one of its remote repositories. Doing this would enable the local Repo B to pull the changes from either the remote Repo A or remote Repo B.

git remote add <name> <clone url>
ex: git remote add RepoA https...

Your local Repo B can then pull the changes from remote Repo A. but instead of origin, you specify the remote branch. In this case its RepoA.

git pull <name>/<branch name>
ex: git pull RepoA/master

Upvotes: 2

Related Questions