• Home
  • About
  • Schedule
  • Sessions
  • Git @ ZI
  • Code of Conduct

Contents

  • This session
  • Learning objectives
  • recipes project
    • Optional:
  • Exercises
    • Connect to remote repositories using SSH
    • Upload your local repository to a remote repository
    • Clone and sync your repository
    • “Private” collaboration with pull requests (using GitHub Flow)
  • 🚀 Bonus exercises
    • Add a README.md
  • Slides
  • Cheatsheet

Integration with GitHub / GitLab

Session 06

Starts at:

Wednesday, 29th of January 2025, 14:00

Slides Chapter: Remotes - Introduction Quiz

This session

In this session, you will work on the following tasks:

  1. Reading: Read the chapter(s) “Remotes - Introduction” in the Version Control Book.
  2. Implementation: Try out the commands in the chapter.
  3. Exercises: Work on the exercises for the recipes project.
  4. Quiz: Test your knowledge with the quiz.

As always:

  1. Try out the commands of this session and play around with them.
  2. Check whether you have achieved the learning objectives.
  3. Ask questions!
  4. Let’s git started!

Learning objectives

At the end of this session, you should be able to answer the following questions and / or achieve the following learning objectives:

💡 You can create a remote repository.
💡 You can connect your local Git repository to a remote repository service like GitHub or GitLab.
💡 You can pull and push changes to and from a remote repository.
💡 You can clone a repository from a remote repository.

recipes project

At the end of this session, you should have accomplished the following:

  1. You created a GitHub account.
  2. You connected your GitHub account to your local Git using SSH.
  3. You created a new private(!) GitHub repository.
  4. You uploaded (i.e., “pushed”) the default branch of your recipes repository to GitHub.

Collaboration Option 1:

  1. You invited a partner from the course as a collaborator to your recipes on GitHub.
  2. You collaborated on a shared project by adding and committing changes to your partner’s repository.

Collaboration Option 2:

  1. You clone your own repository to a different location on your computer.
  2. Stage and commit changes in the repository in this new location.
  3. Push the changes to GitHub and pull them in the original repository location on your computer.

Optional:

  1. You created a short README.md file in your repository.

Please keep the recipes folder! We will continue to use it in the following sessions.

Exercises

Connect to remote repositories using SSH

  1. Generate an SSH key.
  2. Copy the SSH key to your clipboard.
  3. Add the SSH key to the remote repository (for example, GitHub or GitLab).

Upload your local repository to a remote repository

  1. Create an empty repository on the remote repository hosting platform, for example GitHub or GitLab. Make sure to not initialize the repository with any files!
  2. If needed, navigate to your project repository using the command line.
  3. Set the remote URL of your local repository to your remote repository.
  4. Push the changes on your default branch (main or master) to your remote repository.

Clone and sync your repository

  1. Move to a location on your computer where you want to clone a repository.
  2. Clone your remote repository to a different location on your computer.
  3. Stage and commit changes in the new location (consider using a new branch).
  4. Push these new changes to GitHub.
  5. Pull the changes to the repository in the original location.
  6. Delete your newly cloned repository.

“Private” collaboration with pull requests (using GitHub Flow)

  1. Add your exercise partner as a collaborator to your project repository on GitHub.
  2. Clone your partner’s repository.
  3. Create a new branch in your collaborator’s repository.
  4. Add a new entry to your collaborator’s project file (e.g., .txt or .qmd (if you are unsure, where to add the entry, ask your collaborator!)
  5. Add and commit the changes.
  6. Push the changes on the new branch to the remote repository.
  7. Create a Pull Request (on GitLab: Merge Request).
  8. Review the Pull Request that your collaborator made in your repository.
  9. 🚀 Optional: Add additional changes on the branch pushed by your collaborator.
  10. Merge the pull request into your repository.

🚀 Bonus exercises

Add a README.md

  1. Find the option to create a new file on your remote repository in the browser.
  2. Name the file README.md, add a brief description, and provide a commit message.
  3. 🚀 Optional: Play around with Markdown syntax.
  4. Save the README.md file to the repository.
  5. Pull the changes to your local repository.

Slides

How can I download the slides as a PDF file?

To export the slides to PDF, do the following:

  1. Toggle into Print View using the E key (or using the Navigation Menu).
  2. Open the in-browser print dialog (CTRL/CMD+P).
  3. Change the Destination setting to Save as PDF.
  4. Change the Layout to Landscape.
  5. Change the Margins to None.
  6. Enable the Background graphics option.
  7. Click Save.

Note: This feature has been confirmed to work in Google Chrome, Chromium as well as in Firefox.

Here’s what the Chrome print dialog would look like with these settings enabled:

Screenshot of Chrome print dialog with the first slide/page of 43 shown on the left, and print options on the right. The Destination print option has Save as PDF selected.

These instructions were copied from the Quarto documentation (MIT License) and slightly modified.

Cheatsheet

Command Description
git remote Manages remote repositories
git clone Creates a local copy of a repository
git pull Fetches and merges the latest changes from a remote repository into the current branch
git fetch Updates remote tracking branches
git push Uploads local commits to a remote repository
© 2025 Dr. Lennart Wittkuhn
 
License: CC BY 4.0