BoJIHa npocmombI
BoJIHa npocmombI

Reputation: 195

Bitbucket: fork to existing repository

I have empty repository B on bitbucket and I want to fork another one A into my existing repository B. How can I do this? On website bitbucket allows only to fork in new repository.

Upvotes: 4

Views: 3917

Answers (1)

Chris
Chris

Reputation: 136938

I see two options:

  1. If you don't need Bitbucket to call it a fork you can simply clone repository A and push it to repository B. This is most of what a "fork" is.

    git clone [email protected]:user/repo
    cd repo
    git remote add my-clone [email protected]:you/repo-b
    git push --mirror my-clone
    
  2. If you need Bitbucket to call your fork a fork, you can take advantage of the fact that Bitbucket wikis are repositories to make a local copy of your wiki, then delete repository B, then fork repository A to repository B, then push the wiki back to repository B.

    git clone http://bitbucket.org/you/repo-b/wiki repo-b.wiki
    cd repo-b.wiki
    # Have a look at the files in repo-b.wiki and make sure they look complete
    # Then delete repository B from Bitbucket
    # Then fork repository A to repsitory B using the Bitbucket web UI
    # Then push the wiki back:
    git push origin master
    

Upvotes: 3

Related Questions