Reputation: 81
I would like to set up a default repository in GitLab that comes with every new project. So when I check out the new project, I am not checking out an empty repo, but one filled up with my default project folders and files.
Anyone knows how to do this?
Upvotes: 2
Views: 1549
Reputation: 7889
You could setup a base project with all your default folders and files, and then clone that project as the first step in every new project. After cloning it, change the remote to point to a new remote repo and push to it.
The workflow would look like this:
The commands for that would be:
git clone https://gitlab.com/username/base-project new-project
cd new-project
git remote set-url origin https://gitlab.com/username/new-project
git push -u origin master
You could fork each new project off of a base project. This has the benefit that it can be done entirely in the GitLab UI. The base project will have to be in a separate namespace (username or group) though, because GitLab won't let you fork a project into the same namespace as the original project.
The workflow would look like this:
Prior to GitLab v8.6.0 this method would expose the full URL of the repo being imported in the logs. If you import from a private repo and put your username/password in the URL they will be readable in plaintext in the log files. See this issue for more info.
You could import the base project as a new project every time. This also has the benefit that it can be done entirely in the GitLab UI, and you can rename the project before starting the import, so you don't have to worry about having another namespace like in option 2. This method works best if your GitLab instance allows importing from any repo URL.
The workflow would look like this:
https://username:[email protected]/username/base-project.git
.Note that if you have to include your password in the import URL, and your username or password has an @
symbol in it, you'll have to url encode it. So p@ssword
would become p%40ssword
.
Upvotes: 2