Skip to main content

Collaboration with Git and GitHub

Your team’s repository: one place for the course material, your assignments and the trading game, with a teammate check before every hand-in.

Git records every change to your project, so you can see who changed what and go back to any earlier state. GitHub hosts the repository online, so your team works on the same files without sending them around. Both are standard tools in finance and data science jobs.

Bad file management can be a burden

We strongly encourage you to use Git and GitHub for your team work in this course. It is not required: you hand in your assignments on Absalon either way.

Your team repository

Your team keeps one private repository on GitHub for the whole semester, for example aef27-<team>. One of you creates it as a copy of your clone of the course repository, with the R and Python environment, the data folder, the templates and the slides. It stays connected to the course repository, so new course material reaches you with one command. Only the members you invite can see it.

Course repository slides, data, templates Your team repository private, on GitHub copied at the start You Teammate Teammate git pull · git push git pull upstream main Course repository slides, data, templates copied at the start Your team repository private, on GitHub You Teammate Teammate git pull · git push git pull upstream main
  1. Each of you needs a free GitHub account. Your username does not have to be your real name. As a student, you can also apply for the GitHub Student Developer Pack, which includes GitHub Copilot.
  2. One of you creates the repository and invites the others, as described in the technical prerequisites (exercise 0, Working with your team on GitHub): a new private repository on GitHub, then git remote rename origin upstream, git remote add origin … and git push -u origin main in the clone of the course repository.
  3. The others accept the invitation, clone the team repository and connect it to the course repository with git remote add upstream https://github.com/advanced-empirical-finance/course-repository.git.

Everyone then installs the environment with uvr sync and uv sync, and puts the licensed data from Absalon into the data folder. Git ignores those data, so they never end up on GitHub.

Where your work goes

Put everything your team writes into folders of its own: assignment-1, assignment-2, assignment-3 and trading-game. To start an assignment, copy the template and references.bib from mandatory-assignments into the assignment’s folder.

Do not edit the course’s files (lecture-slides, mandatory-assignments, data-raw). Course updates change exactly these files; if you leave them alone, every update arrives without conflicts.

The daily loop

Before you start, get your teammates’ latest work. When you are done, or whenever you reach a step worth keeping, save it as a commit and share it:

git pull                           # your teammates' latest work
# ... work ...
git status                         # what has changed?
git add assignment-1
git commit -m "Estimate the tangency portfolio with monthly returns"
git push

The Source Control panel in Positron (Ctrl-Shift-G) does the same with buttons. A commit message says what you changed and why, in one line.

Split the report so you do not get in each other’s way

Git merges changes in different files, or in different parts of a file, by itself. It only stops when two of you change the same lines. So give each section of your report its own file and pull them into the report with includes:

## Data

{{< include sections/_data.qmd >}}

## Results

{{< include sections/_results.qmd >}}

Each of you works in your own section file, and the report still renders from start to finish. Files whose names start with an underscore are not rendered on their own. If Git does report a conflict, it marks the lines in the file: keep the right version, delete the markers, then git add and git commit.

Before you hand in: the teammate check as a pull request

The quality criteria recommend that a teammate reproduces your report before you hand it in. A pull request is the natural place for this check.

fixes go into the same branch Branch git switch -c assignment-1-check YOU Pull request on GitHub: say what to check YOU Fresh clone uvr sync, uv sync, licensed data TEAMMATE Render do the numbers match the PDF? TEAMMATE Merge into main, then everyone pulls YOU fixes go into the same branch Branch YOU git switch -c assignment-1-check Pull request YOU on GitHub: say what to check Fresh clone TEAMMATE uvr sync, uv sync, licensed data Render TEAMMATE do the numbers match the PDF? Merge YOU into main, then everyone pulls
  1. Whoever finishes the report puts the final version on a branch of its own and pushes it:

    git switch -c assignment-1-check
    git push -u origin assignment-1-check

    On GitHub, click Compare & pull request and write what the teammate should check.

  2. A teammate gets that version in a new folder, installs the environment from scratch, adds the licensed data and renders the report:

    git clone --branch assignment-1-check https://github.com/<username>/aef27-<team>.git check-assignment-1
    cd check-assignment-1
    uvr sync
    uv sync
    # copy the licensed data into data/, then render assignment-1/report.qmd

    If it renders and the numbers match the PDF, approve the pull request on GitHub. If not, comment on what went wrong; fixes go into the same branch.

  3. Merge the pull request on GitHub. Everyone then switches back with git switch main and runs git pull.

New material from the course

When we announce new material, pull it from the course repository into your team repository, and push it so your teammates have it too:

git pull upstream main
git push

If you added packages of your own, Git may report a conflict in uvr.toml, uvr.lock, pyproject.toml or uv.lock. Keep the course’s version, add your packages again and commit:

git checkout --theirs uvr.toml uvr.lock pyproject.toml uv.lock
uvr add <your R packages>
uv add <your Python packages>
git add uvr.toml uvr.lock pyproject.toml uv.lock
git commit -m "Course update; our packages added again"

What never goes into Git

  • Licensed data, such as CRSP. The data folder ignores everything except the public files of the course.
  • Your trading game token. set_token() saves it in .Renviron (R) or .env (Python), which Git ignores. If a token ever ends up on GitHub, tell us and we replace it.
  • Large files: GitHub refuses files over 100 MB. Save results as compact parquet files, or recompute them.

Run git status before every commit: it lists what would be added.

Git with an AI assistant

Your AI assistant in Positron, or an agent such as Claude Code or GitHub Copilot, can run every command on this page and resolve most conflicts for you. Read what it changed before you commit (Source Control panel or git diff), and make sure the commit message says what the change does.

To learn more, read Happy Git and GitHub for the useR by Jenny Bryan, which also applies to Python.