- COMP.CS.300
- 2. Git
- 2.3 Course-upstream to pull new instructions
Course-upstream to pull new instructionsΒΆ
course-upstream
is needed for getting instructions
and updates to weekly exercises and assignment. The course personnel will distribute the needed
files to students via the upstream, that is student_template_project
.
After setting up the system, all students need to do is to pull the changes.
In order to get updates, new tests and modifications from the course upstream repository, you have to add the student_template_project as a remote to your own git repository. This way, you can pull from the remote and get the changes in your repo.
The address of the course student repository: git@course-gitlab.tuni.fi:compcs300-october-2024/student_template_project.git
From this point on, let us call it course-upstream. So, course-upstream is the repository where course-personnel updates the tests, and from which students may pull updates to their own repositories.
After you have successfully cloned your own repository to your own computer, you can add the course-upstream to your local remotes like so:
git remote add course-upstream git@course-gitlab.tuni.fi:compcs300-october-2024/student_template_project.git
After adding the remote you can view your remotes by
git remote -v
and you can pull from the course-upstream by
git pull course-upstream main
That tells git to pull latest changes from the course-upstream remote and merge them into your local main branch. It will ask you to make a merge commit message. You most likely should not change it in any way from the default message.
At this stage, it is likely you encounter the following error message:
fatal: Need to specify how to reconcile divergent branches.
In this case, you need to configure Git to merge the remote branch into your local branch:
git config pull.rebase false
In case, the merge still does not succeed because of the error message:
fatal: refusing to merge unrelated histories
add the option:
git pull course-upstream main --allow-unrelated-histories
Now, if what follows is a merge failure:
Automatic merge failed; fix conflicts and then commit the result.
Here's how you can solve the conflicts:
- Open Each unmerged file: Open each of the unmerged files listed in a text editor.
- Locate and Resolve Conflicts: Look for conflict markers (<<<<<<<, =======, and >>>>>>>). Between the <<<<<<< and ======= will be your changes, and between ======= and >>>>>>> will be the conflicting changes from the merge. Decide which changes to keep, edit the file accordingly, and remove the conflict markers.
-
Stage the Changes:
After you resolve each conflict in a file, stage the file by running
git add ~filename~
-
Commit the Changes:
After you resolve all conflicts, run
to commit the changes.git commit -m "Merge changes from course-upstream" -a
Potential merge conflicts are to be solved manually.
Beware that
git pull
will still pull from your own repository at course-gitlab.tuni.fi and NOT from the course-upstream.
The workflow with git repos is the following:
- The course personnel adds material to the course-upstream
- Students get notified in Teams and in Plussa News
- The students then will pull from the course-upstream so that their repositories are updated to contain the latest stuff
A+ presents the exercise submission form here.