Introduction to Git and GitHub

HEGL Illustrating Mathematics Seminar, WS 2025/26
Florent Schaffhauser, Heidelberg University

Git

The Git logo

  • What Git is: A version control system software originally authored by Linus Torvalds in 2005.
  • What Git does: It tracks changes in computer files.
  • What Git is often used for: Coordinating work among people working collaboratively on a project.

Main characteristics: Git is distributed, fast, and efficient in its use of memory space.

GitHub

The GitHub octocat logo

GitHub is a private company that was started in 2008. In 2018, it became a subsidiary of Microsoft. Alternatives are: GitLab, Gittea, Coeberg, SourceHut, etc.

  • What GitHub is: An Internet hosting service for software development and version control using Git.
  • What GitHub does: Provide infrastructure and automation for large projects.
  • What GitHub is usually used for: Host collaborative software development projects.

Repositories

  • The successive versions of a project administered via Git are stored in a Git repository (or repo), which in practice is just the hidden folder .git in your workspace.
  • A GitHub repository means something slightly different: it is basically an interface showing the latest version of a project administered via the Git version control system. But the whole history of the project is also accessible via that interface.
  • A public GitHub repository can be cloned or forked by anyone who wants to use it:
    • If you clone it, then you will be working directly on it.
    • If you fork it, then you create a new copy and you can decide later if you want to contribute to the original repo (requires managing two repos).

Our seminar's repo

Screenshot of the seminar's repository

  • Our seminar's repo is hosted on GitHub as a private repo.
  • We will add you to it as collaborators.
  • We want you to clone the repo, not fork it. So first, we are going to learn how to do that.

GitHub Desktop

  • If you have never used Git, you may find it convenient to download GitHub Desktop, an application that enables you to perform basic Git operations via a graphical interface.
  • For instance, if you go to a repo's webpage on GitHub, you have the option to open that repo in GitHub Desktop, which means cloning it on your machine.

Using Git in an IDE

Screenshot of VS Code source control

  • You can also use a code editor such as VS Code to perform Git operations on your repo. This is quite convenient but perhaps slightly confusing at first.
  • We will see next some basic operations that can be performed on any repo.
  • GitHub Desktop provides a simplified framework in which to handle these tasks.

Cloning a repo

  • Cloning a repo means creating a copy of it on your machine. When you do that, you copy the entire history of the repo. You can use the URL of the repo to clone it.
  • You can clone a repo via the command line (git clone <url>) or using GitHub Desktop. If you then click on History, it should look like the screenshot above.

Branches

Git branches

  • A characteristic feature of Git is the existence of branches, which allow for distributed and parallel workflows that can later be merged back into the main workflow.
  • Use cases:
    • Develop new features.
    • Fix bugs.
    • Collaborate on a project, typically in software development.

Creating a new branch and switching to it

  • Creating a branch enables you to use the repo to test or develop new features. You can do that using GitHub Desktop or using the command git branch <branch_name>.
  • To work on your presentation, we ask you:
    1. To create your own branch (you can name it after your talk's topic).
    2. To duplicate the files you want to work on and to work on the copy.

Tracking a file's history

  • In Git, there are three distinct workspaces:

    • The working tree, where you work on the files.
    • The index tree, where you prepare the files you want to add to the repo.
    • The repository, where you store the various versions of your files.
  • To start tracking a file's history, you need to add that file to the index. GitHub Desktop does that for you (you have to uncheck a file if you do not want it to be tracked).

  • The above also applies when a file is modified (the modified version may or may not be added to the index). The command line to index a file is the following:

    git add GitIntro/Git.md
    

Committing files to a repo

  • Committing some files means generating a new version of the repo that includes those (new or modified) files.

  • By default, GitHub Desktop adds all modified files to the commit, but you can uncheck those that you do not want to add.

  • When you commit files to a repo, you must include a commit message. It is good practice to add an informative commit message when you do that.

    git commit -m "Add draft for Git presentation"
    
  • The interface in GitHub Desktop lets you enter a commit message as well as more detailed explanations.

Pull Requests

  • A pull request (or PR) is a proposal to merge a set of changes from one branch into another (often into the main branch).
  • Pull requests are used constantly when collaborating on a project.
  • In a pull request, collaborators can review and discuss the proposed set of changes before they integrate the changes into the main codebase.
  • Pull requests display the differences, or diffs, between the content in the source branch and the content in the target branch.
  • For more details, we refer you to the GitHub documentation.

Assignment

  1. Install Git. You can also follow the instructions on GitHub to do so.
  2. If you feel it might be useful, download GitHub Desktop and install it.
  3. Clone the seminar repo.
  4. Create a new branch and switch to it.
  5. Download VS Code and install it.
  6. Open the cloned repo in VS Code.
  7. Create a new folder and copy the file IntroTalk/SeminarOrganisation.md to it.
  8. Use GitHub Desktop to commit the new file to the repo.

If you do not want to install anything for now, you can open the repo in a Codespace (directly from the GitHub webpage of our repo) and work on steps 5, 6, 7 there.

References

To learn more about version control using Git, you can either read the Atlassian Git tutorial, or watch the following video:

Thumbnail and link to Mosh's 1h tutorial about Git