Git Remotes

You want to set up the git repo on your laptop so that:

Here are the steps to achieve that.

I first made a repo called test-teacher-repo on Forgejo.

  1. Clone the repo to your laptop and name it test-student-repo

    git clone ssh://forgejo@git.auc-computing.nl/bon/test-teacher-repo.git test-student-repo
    cd test-student-repo
    
  2. Add the student remote. Use your own Forgejo repo here.

    git remote add student ssh://forgejo@git.auc-computing.nl/bon/test-student-repo.git
    
  3. Create the python branch

    git checkout -b python
    
  4. Configure pull behavior for main

    git config branch.main.remote origin
    git config branch.main.merge refs/heads/main
    

    (This is likely already set by the clone, but this makes it explicit.)

  5. Configure push behavior for pythonstudent/main

    git config branch.python.remote student
    git config branch.python.merge refs/heads/main
    git config branch.python.pushRemote student
    
  6. Then to ensure it pushes to main (not python) on the remote, set the push refspec. Also prevent git from grumbling about cherry picks.

    git config remote.student.push refs/heads/python:refs/heads/main
    git config set advice.skippedCherryPicks false
    
  7. Verify

    git remote -v
    git config --list | grep branch
    

Now when you are on branch main and you do git pull then it comes from teacher and when you are on branch python and you git push it goes to the main branch on your student repo.

Author: Breanndán Ó Nualláin <o@uva.nl>

Date: 2026-04-23 Thu 15:57