Skip to content

Commit 75375fd

Browse files
committed
feat(16-oopsy): Create the oopsy chapter
1 parent 8a68e2f commit 75375fd

File tree

4 files changed

+112
-24
lines changed

4 files changed

+112
-24
lines changed

.obsidian/workspace.json

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,35 @@
44
"type": "split",
55
"children": [
66
{
7-
"id": "f854b54e1c2c8592",
7+
"id": "8a32cc27797a4d1e",
88
"type": "tabs",
99
"children": [
1010
{
11-
"id": "e74c320159094cdf",
11+
"id": "20e1b75c65c12b41",
1212
"type": "leaf",
1313
"state": {
1414
"type": "markdown",
1515
"state": {
16-
"file": "docs/18-workflows.md",
16+
"file": "docs/15-diffs.md",
17+
"mode": "source",
18+
"source": false
19+
}
20+
}
21+
},
22+
{
23+
"id": "411e3e90803f0f69",
24+
"type": "leaf",
25+
"state": {
26+
"type": "markdown",
27+
"state": {
28+
"file": "docs/16-oopsy-undoing-changes.md",
1729
"mode": "source",
1830
"source": false
1931
}
2032
}
2133
}
22-
]
34+
],
35+
"currentTab": 1
2336
}
2437
],
2538
"direction": "vertical"
@@ -85,7 +98,7 @@
8598
"state": {
8699
"type": "backlink",
87100
"state": {
88-
"file": "docs/18-workflows.md",
101+
"file": "docs/16-oopsy-undoing-changes.md",
89102
"collapseAll": false,
90103
"extraContext": false,
91104
"sortOrder": "alphabetical",
@@ -102,7 +115,7 @@
102115
"state": {
103116
"type": "outgoing-link",
104117
"state": {
105-
"file": "docs/18-workflows.md",
118+
"file": "docs/16-oopsy-undoing-changes.md",
106119
"linksCollapsed": false,
107120
"unlinkedCollapsed": true
108121
}
@@ -125,11 +138,12 @@
125138
"state": {
126139
"type": "outline",
127140
"state": {
128-
"file": "docs/18-workflows.md"
141+
"file": "docs/16-oopsy-undoing-changes.md"
129142
}
130143
}
131144
}
132-
]
145+
],
146+
"currentTab": 1
133147
}
134148
],
135149
"direction": "horizontal",
@@ -147,15 +161,18 @@
147161
"table-editor-obsidian:Advanced Tables Toolbar": false
148162
}
149163
},
150-
"active": "e74c320159094cdf",
164+
"active": "fdba8d3352084196",
151165
"lastOpenFiles": [
166+
"docs/15-diffs.md",
167+
"docs/16-oopsy-undoing-changes.md",
168+
"16-.md",
169+
"assets/pasted-image-20240315113136.png",
170+
"docs/18-workflows.md",
152171
"assets/Pasted image 20240314154647.png",
153172
"assets/Pasted image 20240314154551.png",
154-
"docs/15-diffs.md",
155173
"assets/diff-difference.png",
156174
"assets/diff-hunk-headers.png",
157175
"assets/diff-header.png",
158-
"docs/18-workflows.md",
159176
"docs/14-forking-over-code.md",
160177
"assets/Pull-Request-Practice.md",
161178
"assets/collaboration.png",
@@ -166,7 +183,6 @@
166183
"assets/pasted-image-20240314105028.png",
167184
"assets/pasted-image-20240314102512.png",
168185
"assets/front-cover.svg",
169-
"assets/back-cover.svg",
170186
"assets/BLANK_README.md",
171187
"LICENSE.md",
172188
"CHANGELOG.md",
@@ -186,7 +202,6 @@
186202
"docs/07-ignore-me.md",
187203
"docs/05-global-settings.md",
188204
"docs/04-git-started.md",
189-
"docs/02-getting-ready.md",
190205
"docs",
191206
"assets/brave_dWSQwZYc3F.mp4",
192207
"themes",
37.2 KB
Loading

docs/15-diffs.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,31 @@ When you run a merge – it is asking the same question.
1212

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

15+
### Git Merge explained using Soldiers
16+
17+
<iframe width="560" height="315" src="https://www.youtube.com/embed/4zw7dO46XSQ?si=0ssNcD8S-ukHV3R4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
18+
19+
1520
## What is the difference?
1621

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

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

26+
You saw an example of differences when you ran a pull request.
2127

22-
•You saw an example of differences when you ran a pull request
23-
24-
•Discuss on what levels were differences highlighted (folder/file/line/word/character)?
25-
28+
![Inside the Pull Request Files Changed - post merge](../assets/pasted-image-20240315113136.png)
2629

2730
## When can diffs be seen?
2831

29-
•Between files
30-
31-
•Between commits
32+
You are able to view diffs between a number of 'objects' that make up the Git version control 'history'.
3233

33-
•Between staging (index) and the object database (repo)
34-
35-
•Between the working copy and any of the above
34+
You may look at diffs between:
3635

36+
- Files
37+
- Commits
38+
- Staging (index) and the object database (repo)
39+
- The working copy and any of the above
3740

3841
# Diff Interpretation
3942

@@ -83,10 +86,19 @@ For example:
8386

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

89+
## Git Diff Explained
90+
91+
<iframe width="560" height="315" src="https://www.youtube.com/embed/vXN50AmJjgY?si=-hRWjzRZfKLPoOtt" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
8692

8793

8894
# References
8995

9096
Content based on the following:
9197

92-
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].
98+
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].
99+
100+
www.youtube.com. (n.d.). _Git Diff - Explained_. [online] Available at: https://www.youtube.com/watch?v=vXN50AmJjgY [Accessed 15 Mar. 2024].
101+
102+
103+
104+
[Forking](14-forking-over-code/md) | [Undoing changes](16-oopsy-undoing-changes.md)

docs/16-oopsy-undoing-changes.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Undoing Changes
2+
3+
You've made an error in your commits, merges or such ... do not worry, it happens to the best of us.
4+
5+
Remember that Git stores EVERYTHING.
6+
7+
The problem is that this isn't always the best thing.
8+
9+
We will make errors such as:
10+
- Accidently add a file you did not want to add.
11+
- Make a commit you didn’t intend to commit (too soon, wrong branch, etc).
12+
- Make a commit and decide you want to change it or its commit message.
13+
- Push a change you didn’t mean to push.
14+
- Make updates to your working copy you want to remove!
15+
16+
Making these errors will happen at some point.
17+
18+
## We will mend it, we will fix it...
19+
20+
Anything can be fixed but the difficulty level does rise pretty quickly. Some may say exponentially.
21+
22+
In general, there are two strategies:
23+
- Revert changes by creating a new commit
24+
- Reset changes by removing them from history
25+
26+
Each has their respective advantages.
27+
28+
| | Git Revert | Git Reset |
29+
| ----------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------- |
30+
| **Operation** | Creates a new commit that undoes changes | Moves the branch pointer to a previous commit |
31+
| **Commit History** | Preserves the original commit history | Modifies the commit history |
32+
| **Branch State** | Updates the branch with a new commit | Moves the branch pointer to a different commit |
33+
| **Working Directory** | Does not modify the working directory | Can optionally modify the working directory |
34+
| **Collaboration** | Safe for shared repositories, as it creates a new commit | Potentially dangerous for shared repositories, as it rewrites the commit history |
35+
| **Use Cases** | Undoing commits, fixing mistakes, reverting changes | Discarding local commits, cleaning up history, resetting to a previous state |
36+
| **Remote Repositories** | Suitable for reverting changes pushed to remote repositories | Not suitable for resetting changes pushed to remote repositories |
37+
38+
## Warning: Reset Danger
39+
40+
WARNING: resets are hazardous!
41+
42+
You run the risk of:
43+
- Losing work.
44+
- Misaligning the commit history (after push).
45+
46+
## Git Reset
47+
48+
<iframe width="560" height="315" src="https://www.youtube.com/embed/iEgCj-d-G5U?si=oHntqxD_L65V_k-E" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
49+
50+
## Git Revert
51+
52+
<iframe width="560" height="315" src="https://www.youtube.com/embed/XJqQPNudPSY?si=RapMB35X1eefT6N4" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
53+
54+
# References
55+
56+
A Shot of Code (2023). _Git Reset Visualized_. [online] www.youtube.com. Available at: https://www.youtube.com/watch?v=iEgCj-d-G5U&list=PLvVKmViR0Z7aKwZjgICrjp0wUYMF_IpGX&index=14 [Accessed 15 Mar. 2024].
57+
58+
A shot of code (2023). _Git Revert - Visualised_. [online] www.youtube.com. Available at: https://www.youtube.com/watch?v=XJqQPNudPSY&list=PLvVKmViR0Z7aKwZjgICrjp0wUYMF_IpGX&index=15 [Accessed 15 Mar. 2024].
59+
60+
61+
[Diffs](./docs/14-diffs.md) | [Stashing](./docs/17-stashing.md)

0 commit comments

Comments
 (0)