简体   繁体   中英

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:

  • From github I created a branch off of Master called 'gh'.
  • From bitbucket I created a branch from Master called 'bb'.

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM