Creating the remote repository
Overview
Teaching: 10 min
Exercises: 15 minQuestions
How do I create a repository and share code?
Objectives
Upload your simple readme file
This episode assumes
- You’ve uploaded your public key to gitlab and verified that it’s working
In this episode we’ll finally push something to a public gitlab repository.
Creating an empty repository on gitlab
Go to gitlab.cern.ch and click the little “plus” dropdown icon near the center of the top bar, and select “New project”.
This will bring you to a dialog page to create the project. The important fields are:
- The “project name”: in principal this can be anything, but to make
things less confusing we’d recommend using the same name you used
locally. In this example this is
dan-example
. - The “visibility level”, there are three levels allowed:
- Private: only you and people you “share” the project with are allowed to see it.
- Internal: everyone with a CERN account can see the project. This will not hide anything from e.g. CMS.
- Public (use this): everyone with the URL can see the project. Unless someone holds a gun to your head everything should be public.
Note that there is no option here to make projects “ATLAS-only”, which is fine: our code is all public anyway.1 More on permissions can be found on gitlab’s docs.
- The “Initialize repository with a README” checkbox. Do not check this, we’ll upload the readme from your local repository.
The “project description” might be useful, but in general this should be explained in the README.
Click the “Create Project” button on the bottom. You should be presented with a page that gives the name of the project and says “The repository for this project is empty”.
Make sure you keep track of the URL for this page: this is where your public code will live from now on.
Pushing your local project
On the empty project page there are instructions to push an existing project. Unfortunately CERN uses a much more complicated authentication scheme than ssh by default, so these can be confusing.
Click the blue “clone” button on the upper right side of the page. It will give you multiple options, click the “copy URL to clipboard” button next to “Clone with SSH”.
Now you need to go back to your terminal and tell your local repository that a remote repository lives at this URL.
git remote add origin ssh://git@gitlab.cern.ch:7999/rest/of/url.git
where the last string starting with ssh://
… is the URL you just copied.
Now try pushing your local project!
git push -u origin master
Once this is done, refresh the browser in your gitlab page. You should see your README now!
Notes
-
Note that while our code is public by default, and you should feel free to create public documentation in the twiki sandbox or by adding twikis to your gitlab repositories. Our physics documentation is internal until approved. Within the physics repositories we use LDAP to periodically synchronize the gitlab user list with e-groups. The procedure is slow error-prone so we won’t discuss it here. ↩
Key Points
Initializing a new repository is very easy
Share your code as appropriate