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.
Step 1. Prepare the new computer
Section titled “Step 1. Prepare the new computer”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}.gitYou 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.
Step 3. Push before you switch computers
Section titled “Step 3. Push before you switch computers”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 pushStep 4. Pull before you start working
Section titled “Step 4. Pull before you start working”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 pullStep 5. Done
Section titled “Step 5. Done”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.