This page shows a typical scenario where your fork conflicts with the teacher's updates, and how to resolve it using VS Code.
Teacher adds an emoji to the greeting in greet.js:
function greet(name) {
console.log(`π Hello, ${name}!`);
}
You add a default parameter and change the wording:
function greet(name = 'World') {
console.log(`Hey, ${name}!`);
}
You commit and push this change to your fork.
You run (in terminal or VS Code):
git remote add upstream https://github.com/J2K101000101/Design-and-program-online-experiments-06SE200o800i-.git
git fetch upstream
git checkout main
git merge upstream/main
Because both changed the same functionβand the signature line differsβGit reports a merge conflict that includes the signature.
After the merge attempt, greet.js looks like this:
<<<<<<< HEAD
function greet(name = 'World') {
console.log(`Hey, ${name}!`);
=======
function greet(name) {
console.log(`π Hello, ${name}!`);
>>>>>>> upstream/main
}
The conflict markers show:
<<<<<<< HEAD β your version (with default parameter and "Hey")======= β divider between your version and the incoming version>>>>>>> upstream/main β the teacher's version (without default, with emoji)Click inside the conflicted area. Above the markers you'll see options:
Suppose you want to keep the emoji from the teacher and your default parameter. Neither automatic option gives that exact result, so you'll need to manually edit the file. For example:
After manual editing, the desired combined code is:
function greet(name = 'World') {
console.log(`π Hello, ${name}!`);
}
If you also want to keep your "Hey" wording (e.g., `π Hey, ${name}!`), you can write that manually.
upstream (once).git fetch upstream.upstream/main into your local main.This workflow keeps your fork in sync with the teacher's updates while preserving all your own work.