This is an archived version of the course. Please find the latest version of the course on the main webpage.

Chapter 5: Objectify your robot!

Pushing to remote repository

face Josiah Wang

Once you’re done, GitLab will bring you to the project page.

It should also tell you that “The repository for this project is empty”, and gives you some instructions for different ways you can fill up your repository. You can just start from nothing, or start from an existing folder on your hard drive (it does not even have to be a Git repository). In our case, we start from an existing repo (the last set of instructions).

Pushing to remote repository on GitLab

Let’s just follow the instructions! I’ve skipped a few instructions as they are not necessary for our case.

git remote add origin git@gitlab.doc.ic.ac.uk:your_username/robot.git will add a new remote repository named origin at git@gitlab.doc.ic.ac.uk:your_username/robot.git.

git push -u origin --all will then push all branches (--all) to the upstream (-u) or remote repository at origin. In Git terms, push sort of means “update the branch on remote repository to be the same as the branch in your local repository”.

user@MACHINE:~$ cd robot
user@MACHINE:~/robot$ git remote add origin git@gitlab.doc.ic.ac.uk:your_username/robot.git
user@MACHINE:~/robot$ git push -u origin --all

If done correctly, you should see your robot project codes appearing on your project page on GitLab. Congratulations! 🎉🎉

If you have problems pushing your repo upstream, first check that your address to your remote repo is correct: git@gitlab.doc.ic.ac.uk:your_username/robot.git.

If you are prompted to enter a password for git@gitlab.doc.ic.ac.uk, it is most likely that you did not set up your SSH keys properly on your computer and/or on GitLab. Follow the instructions in “Part Two” on CSG’s guide to GitLab to add your public key to GitLab.

If you are finding this SSH key thing a hassle, you can always use the HTTPS version of the remote repository instead. The main disadvantage is that you will have to type in and transmit your GitLab username and password each time you push any changes upstream. This might be a bigger security risk because your credentials are being exposed more frequently over the Internet. If you wish to use HTTPS, then remove the remote repository that you added earlier, and replace it with the HTTPS version.

user@MACHINE:~/robot$ git remote remove origin
user@MACHINE:~/robot$ git remote add origin https://gitlab.doc.ic.ac.uk/your_username/robot.git
user@MACHINE:~/robot$ git push -u origin --all

You should see your robot repo on the project page if successful.

This guide on SSH keys might help you understand SSH authentication better, if you are interested (not important for our course!)