You can use this script to publish code wikis from different hierarchies of an existing wiki. This helps you split a wiki into multiple wikis.
Proceed to use the script if you are OK with the following limitations.
- Attachments directory is copied blindly in the split repository. This can add substantial size in some cases without using most of those files.
- File history will be lost. This will create a new wiki all revisions history of your pages will not be available in the new wiki.
- Links referring to files outside your area of split will be broken.
- Azure-Cli should be installed. Refer this for platform specific installation instructions.
- Run
az login
. Use the same AAD account which you use for devops login.
- Git.exe (Download and install git for windows. Linux and Mac have git already installed by default.)
- Git credential manager should have the credentials. You can do this by cloning a private repo from the same account. Clone the repository you want to split and that can be reused in the script too.
split_wiki.ps1 -wikiurl WikiCloneURl -organization DevOpsOrganizationUrl -project ProjectName -path RelativePathToPublishNewWikiFrom -repository NewRepositoryNameForCodeWiki -commitmessage 'Commit Message For The New Wiki Creation'
-
Powershell execution policy on the machine might stop you from using the script. You can bypass the policy to run the script like this-
PowerShell.exe -ExecutionPolicy Bypass
./split_wiki -wikiurl <wikiclone url> -organization https://dev.azure.com/<organizationname> -project <projectname> -path <path to file like /Network/TeamA> -repository <new wiki name> --commitmessage '<commit message>'
- -organization : Organization url where the new wiki is to be hosted. e.g. https://dev.azure.com/officeorg
- -project : Project name where the new wiki is to be hosted.
- -path : Folder path relative from root of repository from where new wiki is to be published. /Network-Team/TSGs/
- -repository : Name of the backing repository for the new wiki. e.g. NetworkTSGs (Wiki name will be created as NetworkTSGs.wiki)
- -wikiurl : [Required - if wikipath is not specified] Clone url of the wiki which is to be split. This can be some non wiki git repository also. e.g. https://dev.azure.com/officeorg/DefaultCollection/Office/_git/officewiki
- -wikipath : [Required - if wikiurl not specified] If the wiki to be split is already cloned locally then use this instead of wikiurl. Directory path where the wiki repository is already cloned locally. e.g. C:\officewiki\
- -commitmessage : Commit message for the new wiki. All files will be added with this in a single commit.
split_wiki.ps1 -wikiurl https://baggaatul24.visualstudio.com/DefaultCollection/WikiMigrationScript/_git/abc123 -organization https://dev.azure.com/myorganization -project DevopsTest -path /Network/TeamA -repository TeamAWiki -commitmessage 'Automated - Split wiki from main wiki'
OR
If you already have the wiki repo cloned locally you can use -wikipath to point the script to use the cloned repo
split_wiki.ps1 -wikipath c:/officewiki/ -organization https://dev.azure.com/myorganization -project DevopsTest -path /Network/TeamA -repository TeamAWiki -commitmessage 'Automated - Split wiki from main wiki'
- Powershell execution policy might disallow unsigned scripts. You can bypass the policy by running the script like below-
PowerShell.exe -ExecutionPolicy Bypass ./split_wiki -wikiurl <wikiclone url> -organization https://dev.azure.com/myorganization -project DevopsTest -path /Network/TeamA -repository TeamAWiki --commitmessage 'Splitting my team wiki from main wiki'
The user '' does not have permissions for the action.
. You do not have appropriate permissions for creating a repository in the project. Get the permissions from the Administrator to try again.- git failure - Verify that the git clone is working on your machine for any repository in the same account.
- If you see path too long issues in windows. Use
git config --system core.longpath true
to allow long paths in git.