Skip to content

Git and multiple computers

A big advantage of Git is that you can keep your work in sync across several computers — for example, a computer on campus and one at home. Tobias shows how in this video.

10:31

Every computer you want to work from needs Git installed and configured with your name, your student email and its own SSH key registered with GitLab — see Set up Git. An SSH key can’t be shared between computers: generate a new one on the new computer and add it as an additional key on your GitLab account.

Step 2. Clone the repository on the new computer

Section titled “Step 2. Clone the repository on the new computer”

The first time you work from a new computer, you need to fetch your own copy of the repository:

git clone git@gitlab.lnu.se:2dv515/student/{YOUR USERNAME}/{PROJECT}.git

You find the full clone address under Clone on the repository’s page in GitLab — choose the SSH variant, since you have already set up an SSH key.

Before you leave a computer, make sure all your work is in the remote repository (GitLab), not just locally on that computer:

git add .
git commit -m "..."
git push

When you sit down at a computer where you have already cloned the repository, always start by fetching the latest, so that you start from the same code you left on the other computer:

git pull

As long as you stick to the routine — pull when you sit down, push before you get up — you can switch freely between any number of computers without losing track of your work.

CCBY