Git GitLab Getting Started
GitLab Account
Go to GitLab and sign up for an account:
Note: Remember to use the same e-mail address you used in the Git config.
Create a Repository on GitLab
Now that you have made a GitLab account, sign in, and create a new Repo:
Select a "Blank Project", and fill in the relevant details:
We will go over the different options and what they mean later. But for now, choose Public (if you want the repo to be viewable for anyone) or Private (if you want to choose who should be able to view the repo). Either way, you will be able to choose who can contribute to the repo.
Then click "Create repository".
Push Local Repository to GitLab
Since we have already set up a local Git repo, we are going to
push
that to GitLab:
Copy the URL, or click the clipboard marked in the image above.
Now paste it the following command:
Example
git remote add origin https://gitlab.com/w3schools-test/hello-world.git
git remote add origin URL
specifies that you are adding a remote repository, with the specified URL
, as an origin
to your local Git repo.
Now we are going to push our master branch to the origin url, and set it as the default remote branch:
Example
git push --set-upstream origin master
Enumerating objects: 22, done.
Counting objects: 100% (22/22), done.
Delta compression using up to 16 threads
Compressing objects: 100% (22/22), done.
Writing objects: 100% (22/22), 92.96 KiB | 18.59 MiB/s, done.
Total 22 (delta 11), reused 0 (delta 0), pack-reused 0
To https://gitlab.com/w3schools-test/hello-world.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Note: Since this is the first time you are connecting to GitLab, you will get some kind of notification you to authenticate this connection.
Now, go back into GitLab and see that the repository has been updated: