Skip to content

Commit a3693aa

Browse files
authored
Merge pull request #10 from AdyGCode/dev
Dev
2 parents 3bba3c1 + 68ed66b commit a3693aa

File tree

6 files changed

+210
-28
lines changed

6 files changed

+210
-28
lines changed

.obsidian/workspace.json

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +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",
12+
"type": "leaf",
13+
"state": {
14+
"type": "markdown",
15+
"state": {
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",
29+
"mode": "source",
30+
"source": false
31+
}
32+
}
33+
},
34+
{
35+
"id": "4ccbe8c51ef9a5f7",
1236
"type": "leaf",
1337
"state": {
1438
"type": "markdown",
@@ -19,7 +43,8 @@
1943
}
2044
}
2145
}
22-
]
46+
],
47+
"currentTab": 2
2348
}
2449
],
2550
"direction": "vertical"
@@ -129,7 +154,8 @@
129154
}
130155
}
131156
}
132-
]
157+
],
158+
"currentTab": 1
133159
}
134160
],
135161
"direction": "horizontal",
@@ -147,15 +173,19 @@
147173
"table-editor-obsidian:Advanced Tables Toolbar": false
148174
}
149175
},
150-
"active": "e74c320159094cdf",
176+
"active": "4ccbe8c51ef9a5f7",
151177
"lastOpenFiles": [
178+
"docs/17-stashing.md",
179+
"docs/18-workflows.md",
180+
"docs/16-oopsy-undoing-changes.md",
181+
"docs/15-diffs.md",
182+
"16-.md",
183+
"assets/pasted-image-20240315113136.png",
152184
"assets/Pasted image 20240314154647.png",
153185
"assets/Pasted image 20240314154551.png",
154-
"docs/15-diffs.md",
155186
"assets/diff-difference.png",
156187
"assets/diff-hunk-headers.png",
157188
"assets/diff-header.png",
158-
"docs/18-workflows.md",
159189
"docs/14-forking-over-code.md",
160190
"assets/Pull-Request-Practice.md",
161191
"assets/collaboration.png",
@@ -166,7 +196,6 @@
166196
"assets/pasted-image-20240314105028.png",
167197
"assets/pasted-image-20240314102512.png",
168198
"assets/front-cover.svg",
169-
"assets/back-cover.svg",
170199
"assets/BLANK_README.md",
171200
"LICENSE.md",
172201
"CHANGELOG.md",
@@ -185,8 +214,6 @@
185214
"docs/09-git-history.md",
186215
"docs/07-ignore-me.md",
187216
"docs/05-global-settings.md",
188-
"docs/04-git-started.md",
189-
"docs/02-getting-ready.md",
190217
"docs",
191218
"assets/brave_dWSQwZYc3F.mp4",
192219
"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](14-diffs.md) | [Stashing](17-stashing.md)

docs/17-stashing.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Stashing Changes
2+
3+
We all know what squirrels and other animals do, the put away food for harsh times. They create a secret stash.
4+
5+
Mush like this, Git also has the ability to stash.
6+
7+
Stashing is simply putting work aside whilst you do something else.
8+
9+
## Stashing
10+
11+
A common situation for the use of stashing is when uncommitted changes get in the way of branching.
12+
13+
This often occurs when one branch is ahead of your working copy. The act of switching to the other branch would then lead to git clobbering your changes.
14+
15+
Thankfully, Git will not let that happen.
16+
17+
So what do you do? Have a think how you could resolve the problem.
18+
19+
### This is one possible solution
20+
21+
So when the above scenario occurs you would have to:
22+
23+
- Copy the changes – you are not sure what files changed, so you probably grab everything (yuck!)
24+
- Copy to another folder (yuck yuck)
25+
- Use git reset --hard to DESTROY the working copy changes (yuck yuck yuck)
26+
- Switch to the branch
27+
- Do work
28+
- Switch back, copy all the files back and really really hope you didn’t stuff everything up
29+
30+
### Or... Making Life Easier
31+
32+
That is both nasty and long winded... so we can make it easier by using a stash of changes:
33+
34+
- git stash
35+
- switch
36+
- switch back
37+
- git stash pop
38+
39+
And there you have it... we are done!
40+
41+
## This is a Public Service Announcement
42+
43+
Git stash is sometimes not taught in an introduction to Git.
44+
45+
The problem with this it that it is just about the most useful command you can find to make working with Git seamless.
46+
47+
This is particularly true if you are branch/working with a remote, that is, using git as intended!
48+
49+
# Time for your Supplements
50+
51+
This video is on Git Stash... The audio at the start may be a little off centre.
52+
53+
<iframe width="560" height="315" src="https://www.youtube.com/embed/adzewZEj2Pg?si=KJKuu2p7pTi3soDL" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
54+
55+
# References
56+
57+
Adhikary, T. (2023). _10 Git stash commands every developer should know_. [online] GreenRoots Blog - Tapas Adhikary. Available at: https://blog.greenroots.info/10-git-stash-commands-every-developer-should-know [Accessed 15 Mar. 2024].
58+
59+
Programming Peanut (n.d.). _[Git] What is Git Stash and how to use it_. [online] www.youtube.com. Available at: https://www.youtube.com/watch?app=desktop&v=adzewZEj2Pg [Accessed 15 Mar. 2024].
60+
61+
62+
63+
---
64+
65+
[Undoing Changes](docs/16-oopsy-undoing-changes.md) | [Workflows](18-workflows.md)

docs/18-workflows.md

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The video by Nick Chapsas "Getting started with branching workflows, Git Flow and GitHub Flow" provides a summary of these two workflows.
44

5-
[Getting started with branching workflows, Git Flow and GitHub Flow (youtube.com)](https://www.youtube.com/watch?v=gW6dFpTMk8s)
5+
<iframe width="560" height="315" src="https://www.youtube.com/embed/gW6dFpTMk8s?si=H6Hhn5CDRE5BLNSD" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
66

77
## Git Flow Workflow
88

@@ -14,14 +14,18 @@ Here's how it works:
1414

1515
1. **Main Branches**: There are two main branches:
1616
- `main`(or `master`): This is the branch that contains the production-ready code.
17+
1718
- `develop`: This is the branch where all the new features and bug fixes are integrated before being merged into
1819
the`main`branch.
20+
1921
2. **Supporting Branches**: There are also supporting branches for specific tasks:
2022
- `feature`branches: These branches are used to develop new features. When a feature is complete, it is merged back
2123
into the`develop`branch.
24+
2225
- `release`branches: When the`develop`branch is stable and ready for a release, a`release`branch is created from it.
2326
This is where any last-minute bug fixes or documentation updates are made before the release is merged into
2427
the`main`branch and tagged with a version number.
28+
2529
- `hotfix`branches: These branches are used to quickly fix critical issues in the production code (`master`branch).
2630
When the fix is complete, it is merged back into both the`main`and`develop`branches.
2731

@@ -36,24 +40,33 @@ It's designed to work well with GitHub's features and allows for more frequent d
3640
Here's how it works:
3741

3842
1. **Main Branch**: There is only one main branch, typically called`main`or `master`.
43+
3944
2. **Feature Branches**: Whenever you want to work on a new feature or bug fix, you create a new branch from the `main`
4045
branch.
46+
4147
3. **Pull Requests**: When you're ready to merge your changes back into the `main` branch, you create a Pull Request. This
4248
allows others to review your code and provide feedback before merging.
49+
4350
4. **Code Reviews**: The Pull Request triggers a code review process, where team members can discuss the changes,
4451
suggest improvements, or request additional changes.
52+
4553
5. **Merge and Deploy**: Once the code has been reviewed and approved, the feature branch is merged into the `main`
4654
branch. This merged code can then be deployed to production.
4755

4856
GitHub Flow encourages frequent, small updates to the codebase, making it easier to manage and integrate changes.
4957

50-
## Further Reading and Tutorials
5158

52-
Select one or two to review and make notes about.
59+
# References
5360

54-
Feel free to feedback as to what you think about the selected items.
61+
The references show details of any articles, videos and other items that were used in this chapter, plus other, possibly useful items.
62+
63+
Chapsas, N. (2021). _Getting started with branching workflows, Git Flow and GitHub Flow_. [online] www.youtube.com. Available at: https://www.youtube.com/watch?v=gW6dFpTMk8s [Accessed 15 Mar. 2024].
64+
65+
Git Dailies (n.d.). _Guide to Git Flow_. [online] GitDailies: Software Engineering Metrics Made Easy. Available at: https://gitdailies.com/articles/git-flow-guide/ [Accessed 15 Mar. 2024].
66+
67+
68+
Other links
5569

56-
- [Guide to Git Flow (gitdailies.com)](https://gitdailies.com/articles/git-flow-guide/)
5770
- [Git Workflow | Atlassian Git Tutorial](https://www.atlassian.com/git/tutorials/comparing-workflows)
5871
- [How To Use Git Flow Effectively (marketsplash.com)](https://marketsplash.com/tutorials/git/git-flow/)
5972
- [Git Flow | Developer Experience Knowledge Base](https://developerexperience.io/articles/git-flow)
@@ -68,5 +81,9 @@ Feel free to feedback as to what you think about the selected items.
6881
- [Understanding the GitHub Flow | GitHub Guides (gitbooks.io)](https://roachhd.gitbooks.io/github-guides/content/flow/flow.html)
6982
- [Git Flow vs GitHub Flow | Alex Hyett](https://www.alexhyett.com/git-flow-github-flow/)
7083
- [Git Flow vs GitHub Flow: What You Need to Know (youtube.com)](https://www.youtube.com/watch?v=hG_P6IRAjNQ&feature=youtu.be)
71-
-
72-
-
84+
- ...
85+
86+
87+
88+
89+
[Stashing](17-stashing.md) | [...](.)

0 commit comments

Comments
 (0)