Creating a GitLab Project Repo
Creating a GitLab project is an essential skill for anyone following a Git-centric workflow, which you all should be doing.
There are two approaches to this:
- Create a GitLab project on the GitLab site and clone it.
- Create a directory with your stuff in it, initialize it with git, and push it as a new project to GitLab.
The first is best for beginners.
But First …
Login to GitLab.
Click on Projects.
Click the New projects button to the right.
Notice a bunch of stuff to fill out.
Give your project a name. This can be natural language and contain spaces if you want, but watch out for the Project slug it creates below.
Make sure Project URL is pointing to the right group (only one if you don’t have a group or subgroup).
Confirm the Project slug is something people can remember and type. It should automatically be lowercase, no space. Think about the user going to your site.
Decide if you want this to be private or public. (Don’t worry about internal for now.) Pick private by default since you can always make it public later when you want to show it off. This does not affect publishing to Netlify.
Click on Create project.
Notice the stuff on the project page.
- GIT Global Setup — Probably not needed if you already setup GitLab on your workstation.
- Clone Button
Click the Clone button.
Notice there are two URL types,
https. We will be using
Click the clipboard icon next to the URL to copy the URL into your paste buffer.
Switch back to your VSCode and open the terminal.
Navigate into your
Check what is in here with the
ls command to make sure nothing has the same name as the slug of your new project.
Clone using the
git command. You can just paste what you copied, but it is not hard to just remember the format of the URL.
YOURACCOUNT with you actual account.
SLUG with your actual slug.
git clone firstname.lastname@example.org:YOURACCOUNT/SLUG.git
Notice the clone happening.
Don’t worry if you see
warning: you appear to have cloned an empty repository. That is just because you don’t have any files in it yet.
Check to see that it worked.
ls -a SLUG
.git/ directory. Every Git repo gets one. If you happened to ever delete it, it would stop being a Git repo.
Let’s put something in here and test committing and pushing it right away to make sure everything works.
Change into the directory with the
Create a file with the
README.md is a special file that must be capitalized exactly like that.
Now open the
README.md file in VSCode (or
vim) and add some Markdown to describe your project to yourself and others potentially later when (and if) you make your project public.
code -r .
Save the file (and make sure you have Auto-Save on).
Commit and Push the Repo from VSCode
Initializing and Pushing Method