Git and Gitlab lab
The goal here is to create a Gitlab account and push our code in from the server
Go to gitlab.com and create your GitLab account.
https://gitlab.com/users/sign_up
sudo apt install git
Note: This step is not needed for btNOG 10 workshop because VM image already contains git. Run this step incase you want to work on a new fresh machine which does not have your code.
Setup git with your username and email
git config --global user.name "Your name here"
git config --global user.email "email@domain.com"
Upload your existing SSH public key from the server on Gitlab account
cat ~/.ssh/id_rsa.pub
Paste your ssh public key into your GitLab user settings
- Go to your GitLab user settings
- Search for SSH Keys
- Put your server public key on the page.
- Add a title (like “aXX lab server” and hit add key.
- In your server shell/terminal, type the following to test it.
ssh -T git@gitlab.com
- If it says something below, it worked else you might have got the ssh key wrong.
Welcome to GitLab, @username!
If you do not see that message, contact instructor for help and do not proceed further.
- Click on “New project” on the Gitlab homepage after logging in.
- Select “Create Blank project”
- Give project name as btnog10
- Keep visibility “Private”
- Uncheck “Initialize repository with a README”
- Click on create project
- Login to your server
- Go to gitlab project and inside the project click on “clone” button on top right
- Copy the output for clone with SSH
- On your server write
git clone
and paste the URL
(U) Thus full command will look like:
git clone git@gitlab.com:username/repository.git
Once cloned successfully, go inside the cloned directory
Create a file name test.txt and write any text in it
touch test.txt
echo "This is my first code which will be tracked using git" > test.txt
Next, add this file in git tracking using command:
git add test.txt
Next, commit this using
git commit -m "My first commit"
And push this change using command
git push origin main
Ensure this pushed file is visible at Gitlab project by refreshing it.