Skip to content

Commit

Permalink
feat(15-diffs): Start section on diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
PWA-GouldA committed Mar 15, 2024
1 parent a00648d commit 8a68e2f
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 87 deletions.
27 changes: 13 additions & 14 deletions .obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"state": {
"type": "markdown",
"state": {
"file": "docs/14-forking-over-code.md",
"file": "docs/18-workflows.md",
"mode": "source",
"source": false
}
Expand Down Expand Up @@ -85,7 +85,7 @@
"state": {
"type": "backlink",
"state": {
"file": "docs/14-forking-over-code.md",
"file": "docs/18-workflows.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
Expand All @@ -102,7 +102,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "docs/14-forking-over-code.md",
"file": "docs/18-workflows.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
Expand All @@ -125,7 +125,7 @@
"state": {
"type": "outline",
"state": {
"file": "docs/14-forking-over-code.md"
"file": "docs/18-workflows.md"
}
}
}
Expand All @@ -147,14 +147,20 @@
"table-editor-obsidian:Advanced Tables Toolbar": false
}
},
"active": "d22cb632a0379261",
"active": "e74c320159094cdf",
"lastOpenFiles": [
"assets/Pull-Request-Practice.md",
"assets/Pasted image 20240314154647.png",
"assets/Pasted image 20240314154551.png",
"docs/15-diffs.md",
"assets/diff-difference.png",
"assets/diff-hunk-headers.png",
"assets/diff-header.png",
"docs/18-workflows.md",
"docs/14-forking-over-code.md",
"assets/Pull-Request-Practice.md",
"assets/collaboration.png",
"docs/12-remotely-useful.md",
"docs/98-command-line-extras.md",
"docs/15-workflows.md",
"CONTRIBUTE.md",
"docs/98-command-line-extras.md",
"assets/pasted-image-20240314105028.png",
Expand All @@ -167,8 +173,6 @@
"output",
"docs/00-Back.md.md",
"docs/00-Front.md.md",
"assets/pasted-image-20240216114456.png",
"assets/pasted-image-20240216124422.png",
"docs/99-references-and-resources.md",
"docs/08-status-add-commit.md",
"docs/06-read-me.md",
Expand All @@ -183,13 +187,8 @@
"docs/05-global-settings.md",
"docs/04-git-started.md",
"docs/02-getting-ready.md",
"docs/03-repositories-and-folders.md",
"docs/01-what-is-version-control.md",
"docs",
"assets/brave_dWSQwZYc3F.mp4",
"assets/2024-03-01_15_03_52-AdyGCode_git-remote-demo-ii-Brave.png",
"assets/2024-03-01_14_57_49-New-repository-Brave.png",
"assets/2024-03-01_14_57_43-New-repository-Brave.png",
"themes",
"ReadMe.md~",
"02-getting-ready.md~",
Expand Down
2 changes: 1 addition & 1 deletion ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This ReadMe does not need a Table of contents, instead we provide links to each
- [12 Remotely useful](docs/12-remotely-useful.md)
- [13 Why, Hello Dolly](13-why-hello-dolly.md)
- [14 Forking over code](docs/14-forking-over-code.md)
- [15 Workflows](docs/15-workflows.md)
- [15 Workflows](docs/18-workflows.md)
-
- ...
- [99 References and Resources](docs/99-references-and-resources.md)
Expand Down
Binary file added assets/diff-difference.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/diff-header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/diff-hunk-headers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions docs/15-diffs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Diffs

A diff is a standard representation of the difference between text files or sets of text files.

Diffs are designed to be human readable but IDEs can make them easier to work with.

They provide enough fidelity to be used as a patch to the code you are working on.

When you run `git status` the question is “what is the diff?”

When you run a merge – it is asking the same question.

Pull or push – yep, you guessed it...

## What is the difference?

We will want to know there is a difference, but this is often not enough.

When we know there is a difference, we then want to know what the difference is.


•You saw an example of differences when you ran a pull request

•Discuss on what levels were differences highlighted (folder/file/line/word/character)?


## When can diffs be seen?

•Between files

•Between commits

•Between staging (index) and the object database (repo)

•Between the working copy and any of the above


# Diff Interpretation

### Header

The header shows the files being compared. The two versions of the file being compared are represented by `-` and `+`.

| Symbol | Version |
| ------ | ----------- |
| `+` | New Version |
| `-` | Old Version |

These two symbols are associated with each insertion.

For temporally related changes, an insertion in the past is a deletion in the present.

![](assets/diff-header.png)

### Hunk headers

The hunk headers indicate the line numbers that are affected in the ‘-’ file and the ‘+’ file.

![](assets/diff-hunk-headers.png)


### A difference!

The differences are indicated by `+` and `-`, and associated with the relevant files.

| Symbol | File | Version |
| ------ | ------ | ----------------------- |
| `-` | `---` | Original |
| `+` | `+++` | New |
| | common | No change between files |

For example:
```diff
def main():
- greet("Alice")
+ name = input("Please enter your name: ")
+ greet(name)
```

![](assets/diff-difference.png)

### Challenge

What line numbers in each file do these changes relate to?



# References

Content based on the following:

www.oreilly.com. (n.d.). _3. Looking Around: Investigating Your Git Repository - Head First Git [Book]_. [online] Available at: https://learning.oreilly.com/library/view/head-first-git/9781492092506/ch03.html [Accessed 14 Mar. 2024].
72 changes: 0 additions & 72 deletions docs/15-workflows.md

This file was deleted.

0 comments on commit 8a68e2f

Please sign in to comment.