7

I have a git-repo in Azure DevOps that I want to use as a template for starting new repos, but without the commit history of the original. GitHub has this nice feature, however I can't find a good approach in DevOps. Is the only way to clone it, remove .git and bind it to a new empty repo?

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
mtcarsalot
  • 301
  • 2
  • 8
  • There's an outstanding feature request for this: https://developercommunity.visualstudio.com/idea/1135723/repository-template-1.html – riQQ Aug 18 '20 at 15:34
  • I too waiting for this requirement to have OOTB in Azure DevOps. In the meantime, I found Stephen Allwright's useful blog article to do it more cleaner. Read more https://stephenallwright.com/project-template-repository-azure-devops/ – It's actually me May 14 '22 at 06:01

2 Answers2

3

There is no out of the box solution on Azure Repos but you can use this workaround (Using a git repository as the base of a new project):

Instead of doing a full clone only to delete the .git directory again, you can only retrieve the archive of the repository you want to start from.

$ mkdir new-project/
$ cd new-project/
$ git archive --remote="${giturl}" HEAD | tar -x
$ git init
$ git add -A
$ git commit -m "Staring off with revision ${rev} of repository ${repo}."
Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
  • 2
    thanks, this works but its prone to errors. Our solution was to clone the "template" repo, then create a new repo, clone it and manually copy the needed stuff from the template to the new. I feel like a caveman – mtcarsalot Apr 30 '20 at 13:30
0

I am afraid there is currently no such feature as Creating a template repository in Azure devops.

As a workaround, because there is a feature to create a template repository in github, so we can first import the repo from azure devops to github.

enter image description here

Then create a template repo in github, and finally import the created template repo into azure devops.

In addition , I think what you want is a good idea! You can post this feature request on our UserVoice site , which is our main forum for product suggestions. The product team would provide the updates if they view it. Thank you for helping us build a better Azure DevOps.

Hugh Lin
  • 17,829
  • 2
  • 21
  • 25
  • It is not a really a viable solution to put our company stuff on github and import to devops. There is templates for all other features in DevOps but not this. – mtcarsalot Apr 30 '20 at 13:26