Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Start exercise

Here we present an exercise to get you acquainted with git - without knowing in detail what it is. Two people will work together in the same repository, namely the owner and the collaborator. The owner starts, the collaborator may help.

Instruction for repo owner

  1. Go to https://github.com/new. This will lead to a page where you can create a new repository.

  2. Choose a descriptive Repository name. Choose it wisely as your repositories will be shared with teachers (or future colleagues). In some cases, like this online book, the repository name will be part of the URL.

  3. Choose visibility to private, Add Readme (on) and click on the green button with Create repository.

Now you have a repository where you can share and synchronize materials.

  1. Click on Settings (in the top right corner of your screen) and click on Collaborators in the left-hand menu.

  2. Click the Add people button under the Manage access heading.

  3. Type your partner’s (or partners’) username and click on Add <username> to this repository (where <username> is your partner’s username).

Partner accepts invitation

Your partner will receive an email with an invitation to collaborate on the repository. Once accepted, both of you can make changes to the repository, though for now only through the GitHub website...

Going local

These steps will make your work locally available.

Open a terminal and navigate to the root project folder - see Using the terminal for instructions when needed.

Using the terminal, run

git clone <repo>

where <repo> is the url of your repository. You can find this URL by clicking the big green button <> Code, and copying the HTTPS URL.

Open Visual Studio Code and open (File/Open Folder) the folder where your repo was cloned into. The only file that will be in it will be the README.md file.

Exercise

You and your partner can now take turns in writing a poem.

Pulling & Pushing changes

When you have made a local change, your partner won’t see it and will not be able to use it. You’ll have to push your work to the central server (GitHub). In VSC, go to source control using the icon: VSC git icon. You will see something like Figure 1. Follow these steps:

Pushing

  1. Type a Message in the inputbox just above the blue ✓ Commit button.

  2. Click for the dropdown menu and choose Commit & Push.

  3. This will push your changes to the central server.

a picture showing the dropdown menu to make a commit using VSC

Figure 1:A screenshot where to find the source control.

Your work will be now be available for your partner. But in order to work on it, it has to be pulled in locally.

Pull

  1. Open Visual Studio Code, and make sure you have opened the folder of the local repo.

  2. Go to source control using the icon: VSC git icon.

  3. Next to change, click the three dots ... and choose Pull, see Figure 2

a picture showing the dropdown menu to pull from github using VSC

Figure 2:A screenshot where to find the source control and pull from GitHub.

Using the terminal

You are probably used to working with a graphical interface (and your mouse): you click the location you want to go to. In the terminal, you work with commands. You navigate through the terminal using cd <folder> (where <folder> is the folder you want to go to).

Some basic commands: