Search code examples
gitazure-devopsazure-repos

Create template git-repo in in azure devops


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?


Solution

  • 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}."