From 386cbcbdcfd36921cc59fab38b763508ad3889f4 Mon Sep 17 00:00:00 2001 From: 20146886 <20146886@tafe.wa.edu.au> Date: Fri, 5 Sep 2025 10:03:00 +0800 Subject: [PATCH] Merge conflict resolved --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9d338e5..9952904 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is a repo to help you practice diffing! To get started: 1. Fork this repo. -⚠️ IMPORTANT: Fork all branches. Not just `main` + ⚠️ IMPORTANT: Fork all branches. Not just `main` 2. Clone your forked repo: ```bash @@ -23,11 +23,12 @@ A diff is a specific file format that tells you the difference between lines in $$ A = B \circ \text{Apply}(\text{Diff}(A, B)) $$ + That is, the difference between A and B can allow A to be transformed into B and vice versa using a function that **applies** said difference. Let's now look at an example diff: -```diff +````diff diff --git a/README.md b/README.md ① index 7f35690..14cf26a 100644 ② --- a/README.md ③ @@ -45,12 +46,11 @@ This is a repo to help you practice diffing! -Follow these instructions c.a.r.e.f.u.l.l.y. ⑦ +Follow these instructions carefully. -``` +```` Fill in what each of the elements of the diff mean (if you are not sure just guess!): - -**①** +**①** Shows this is a diff in git format. It is followed by the file names being compared. The `a/` and `b/` 'folders' are like virtual folders that usually represent different versions with the newer version being b/ and the older version being a/. **②** @@ -71,6 +71,29 @@ In this example, one line is replaced and 3 additional lines are added in the ne **⑦**: In this case there is a common whitespace in both files bollowed by a change in one line (notice that only one word changed, but the diff does not indicate this). Notice also that this is redundant given the next line! +--- + +**①**: +Shows the difference between README in a and b folders + +**②**: +The hashes of both compared commits + +**③**: +Shows in which way each of the files was changed (something was added/deleted) + +**④**: +Between what lines changes was done + +**⑤**: +Line wasn`t changed + +**⑥**: +Three lines were added at that place + +**⑦**: +c.a.r.e.f.u.l.l.y. was changed into the carefully + Notice that the diff above only showed different **lines** in the file. Including whitespaces. We can also highlight changes at the word level with the --word-diff option: ```diff @@ -106,10 +129,18 @@ git diff --word-diff ``` ## Stashing -> + +<<<<<<< Updated upstream + > Make sure you attempted to fill in your explanation above! -Guess what!? Your lecturer has also got an answer to these questions! They are in another branch though! +# Guess what!? Your lecturer has also got an answer to these questions! They are in another branch though! + +> Make sure you attempted to fill in your explanation above! + +Guess what!? Your lecturer has also got an answer to these questions! They are in another branch, though. + +> > > > > > > Stashed changes Let's go check them out so we can decide whether we like them better. Run the following git commad: @@ -117,7 +148,12 @@ Let's go check them out so we can decide whether we like them better. Run the fo git switch answers ``` +<<<<<<< Updated upstream Did it work? If it did it just means you didn't follow the instructions carefully! +======= +Did it work? If it did, it just means you didn't follow the instructions carefully! + +> > > > > > > Stashed changes If it didn't work, you have yourself a quandary: @@ -129,7 +165,12 @@ Bet you didn't expect an existential crisis learning git (well, you should!). Lucky for you, there is one quality of life option we didn't mention: `git stash`. -This command *stashes* your changes safely away so you can come back to them later. It is like a commit to the "not sure what to do with this yet" branch. +<<<<<<< Updated upstream +This command _stashes_ your changes safely away so you can come back to them later. It is like a commit to the "not sure what to do with this yet" branch. +======= +This command _stashes_ your changes safely away so you can return to them later. It is like a commit to the "not sure what to do with this yet" branch. + +> > > > > > > Stashed changes So let's do that: @@ -147,6 +188,13 @@ pop goes the stash and your changes are back (and no longer on the stash). Okay, stash them again, and then switch to the `answers` branch +<<<<<<< Updated upstream Go ahead. Look at the answers. Notice that some are probably better than yours, some are worse. You want to merge your stashed changes with the current changes. You can do this in this branch (simply pop the stash here) or you can merge the answers into main and then pop your stash. Either way, this time popping the stash will be a bit more complicated because there are changes in the same file that you have made and that your lecturer has made. -So you will have a conflict like any other merge conflict. But by now you are a pro at this! So go ahead, pop the stash and resolve the conflict. +# So you will have a conflict like any other merge conflict. But by now you are a pro at this! So go ahead, pop the stash and resolve the conflict. + +Go ahead. Look at the answers. Notice that some are probably better than yours, and some are worse. You want to merge your stashed changes with the current changes. You can do this in this branch (simply pop the stash here), or you can merge the answers into main and then pop your stash. Either way, this time, popping the stash will be a bit more complicated because there are changes in the same file that you have made and that your lecturer has made. + +So you will have a conflict like any other merge conflict. But by now, you are a pro at this! So go ahead, pop the stash and resolve the conflict. + +> > > > > > > Stashed changes