Problem to solve
We want to provide Instance and Group wide templates for some of our tech stacks.
This is already working, but templates are one to one copys of the template project itself (e.g. contain all commits, branches, releases ,… ) of th eoriginal project and take a long time to initalize (new project from template)
How do we “flatten” the project best before it becoming a template.
How do you do it with github.com source projects. e.g. how does this GitLab Pages examples / plain-html · GitLab
become a flat template without history, or releases in gitlab when you use it.
Steps to reproduce
Make a longer running template source project with commits and releases a template.
And use this template → all releases are still present.
Versions
- GitLab Self Managed [v16.11.1-ee]
kind regards
Hi @anconrad
and welcome to the GitLab Community forum! 
If you want to reduce or rid of all commits, git history, branches, releases for a project, there are a couple options:
Option 1: Easy mode
- Clone the template project locally.
cd
to directory where you cloned the repository
- Run
rm -rf .git
to delete git history of the local clone
- Create a blank project (
DO NOT add select “Initialize repository with a README”)
- Run the following commands to initialize a git repository, set the
remote origin
to be your newly created blank project, add all files in the project to Git, commit these files to the Git repo, and push it:
git init --initial-branch=main
git remote add origin [git@|https://]<URL of new blank repo>
git add .
git commit -m "Initial commit"
git push --set-upstream origin main
Option 2: Rebase/squash git history, manually delete the rest
- Use
git rebase
to squash all commits into one, force push the squashed git history back to main
(or master
).
- Manually (via UI or API) delete all branches and releases and any other unwanted data.