bhb
bhb

Reputation: 2561

Merge/rebase branches across repos

I have a local repo which i was using to commit. Let's call this A with branch named implementation

I also have a github repo which was used for production deployment. Let's call this B. A is sub repo of B which also has the branch implementation (A is in the web folder). It was copied before I made changes. Let's call it C

Now i was committing all my changes to A in implementation branch. I want to merge into C's implementation branch.

Upvotes: 0

Views: 41

Answers (1)

kowsky
kowsky

Reputation: 14459

You can just add your github repo as a remote of your local repository:

git remote add <name_for_remote> <github_repo_url>

where <name_for_remote> is an arbitrary name for your remote github repository and <github_repo_url> is its' adress.

You also have to fetch once to know what's going on upstream:

git fetch <name_for_remote>

Then, you can set the upstream for your local implementation branch:

git branch -u <name_for_remote>/implementation

Your local implementation should be your current checked out branch.

If you git push now, the changes from your local implementation branch will be pushed to the github implementation branch. This will, however, only work without conflicts if the remote branch was not changed since you copied your local repo. You would have to pull, rebase or force push in this case, depending on which changes you want to keep.


Your workflow here looks strange, however. Did you really copy the repository? Why not just clone it, to have your github repo set as the default remote origin? Also, by "sub repo" you mean a copy, as in cp? Also, what does repository B have to do with any of this? You may have to elaborate on which repo was copied/cloned from which to allow a proper answer to your question.

Upvotes: 2

Related Questions