On Gitlab I have a repository that I use as template. Actually I simply copy and paste it every time, however I am wondering if using directly Git it is possible to fork it and create a new repository. If possible, please provide instructions about to do it or any alternatives.
Assistant
Using GitLab to create a new repository from a template is indeed possible and can streamline your workflow. Here's how you can do it, along with some alternatives.
Using GitLab's Built-in Template Feature
Mark the Repository as a Template:
Go to your GitLab repository.
Navigate to Settings > General.
Scroll down to Templates and check the box Mark this repository as a template repository.
Create a New Project from Template:
Go to the GitLab dashboard.
Click on the green New Project button.
Select the Create from template tab.
Your template repository should appear under Custom templates.
Select your template and follow the prompts to create a new repository using that template.
Forking a Repository
In GitLab, the term "fork" is generally used to make a full copy of a repository under your own namespace, keeping its git history. This might not be what you want if you're just looking for a fresh new copy, but if you want to use this approach, here’s how:
Fork the Repository:
Go to your template repository on GitLab.
Click the Fork button at the top right corner.
Select the namespace where you want the new repository to be, and click on Fork project.
Creating a New Repository Manually Using Git
If you're more comfortable using Git commands or if you need more control over the process, you can always duplicate a repository manually:
Whenever you need to create a new project, you can run this pipeline, and it will copy the template to a new repository.
These methods give you options depending on your needs and workflows. For frequent and straightforward use cases, GitLab’s built-in template feature should suffice. For more controlled or automated processes, either manual cloning or using CI/CD might be more suitable.