Copying a Wiki
Asked by mikerb:

I wish to copy a wiki from one repository to another. I have created a git repository on my machine and cloned the wiki. I have created the new repository and wish to upload the contents to the new wiki. The new repository has a wiki defined with the default home.md page.  

I am trying to set up the remote for git for the new repository but am getting stuck. I configure the remote URL with //https:/bitbucket.org/\<user name\>/\<repository name\>/Wiki and then I get stuck, what is the mapping for the wiki head version? I have my Git branch as HEAD but I need a mapping for the remote.   

The documentation says that the wiki is a repository but what is the mapping for uploading?

Any pointers appreciated.


Answers:
author: mikerb
body: I have worked it out. I did a fetch first which created the link between my local repository and the remote. I then added my files from the old Wiki to my local repository and the upload worked.

When adding a remote I had to make sure that I used the default branch name from when the repository was set up in the mapping.


author: Theodora Boudale
body: Hi [@mikerb](/t5/user/viewprofilepage/user-id/1788090) ,

I believe that the push will fail because the wiki in the second repo already has a commit with the default page, and its history is not related to the history of the wiki you are trying to push from.

If the new wiki contains only the default page, and no other commits/changes you want to keep, what you can do is ++force push++ from your local repo (of the wiki you want to copy) to the new wiki.

Please note that the force push will remove the existing history of the new wiki, and will replace it with the history of your local clone.

So, in your local clone of the wiki you want to copy, you can do the following:

```
git remote add second-wiki URL-of-new-wiki
git push -f second-wiki
```

where **second-wiki** is the name of the second remote, feel free to replace with a different one.

Please feel free to let me know if you face any issues or if you have any questions.

Kind regards,  
Theodora

comments: author: mikerb
body: Thanks for the answer, this I tried and it says it was successful but only uploaded 3 items. Should the remote be the url of the repository or include wiki, eg. [https://bitbucket.org/\<user\>/\<repository]()\> or [https://bitbucket.org/\<user\>/\<repository\>/wiki]()?

Should my files be in the folder itself or one called wiki?


author: mikerb
body: See my answer, your answer pointed me in the right direction, thank you


author: Theodora Boudale
body: Hi [@mikerb](/t5/user/viewprofilepage/user-id/1788090), thank you for the update, I'm glad you were able to figure it out.

Just to answer your question as well, the (HTTPS) URL of the wiki should be

```
https://<username>@bitbucket.org/<workspace-id>/<repo>.git/wiki
```

The URL

```
https://<username>@bitbucket.org/<workspace-id>/<repo>
```

is for the repo that contains the wiki.

You can also find the URL if you open the wiki in Bitbucket website, and then select the **Clone wiki** link (from the top right corner). This will show you the git clone command along with the URL for this specific wiki.


Tags: bitbucket-cloud

cloud

git

wiki