haydnD
haydnD

Reputation: 2293

How to merge repository from bitbucket to GitHub

I have a repository in bitbucket. We also have code in GitHub for the same app. We need to pull and merge the code from bitbucket into the repo in GitHub.

What I'm tried:

Then from 'gh' I ran "git pull https:{{url_to_bitbucket_repo}}.git".

When running this command I receive an error saying:

error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict. 

This seems like it would be an easy thing to do but I'm having issues finding the right 'steps / git commands'. What would be the correct steps / commands for accomplishing this?

Upvotes: 0

Views: 1211

Answers (1)

Edwin Torres
Edwin Torres

Reputation: 2864

I'm assuming you want to try and merge the code histories from Bitbucket and GitHub. This worked for me:

  1. Go into your local GitHub repo folder.
  2. Check out the gh branch and make sure it is clean (git status).
  3. Add a remote to your Bitbucket repo: git remote add bitbucket <insert_your_bb_url>
  4. Pull from the bb branch of your bitbucket remote: git pull bitbucket bb --allow-unrelated-histories Note: this will merge files if necessary, possibly creating merge conflicts.
  5. Push to the gh branch of your remote: git push origin gh

Upvotes: 1

Related Questions