Skip to content

Commit d994d76

Browse files
authored
Add pitchme_to_readme make target (#17)
* Add pitchme_to_readme make target * Extract exercises from Git content. Create new folder for Git exercises as c01-git-<ex number> * Refactor scripts from Makefile to scripts/ * Update README.md (#18) * Rename folders, exercises, and exercise answer files
1 parent 172be09 commit d994d76

File tree

10 files changed

+281
-67
lines changed

10 files changed

+281
-67
lines changed

Makefile

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
ORG_NAME?=devopsacademyau
2-
REPO_NAME?=academy
3-
FOLDER_NAME?=
1+
export ORG_NAME?=devopsacademyau
2+
export REPO_NAME?=academy
3+
export BRANCH_NAME?=
4+
export FOLDER_NAME?=
45

56
presentation:
67
docker-compose up -d
78
sleep 5
89
open "http://localhost:9000/${ORG_NAME}/${REPO_NAME}?p=${FOLDER_NAME}"
910

1011
stop:
11-
docker-compose down
12+
docker-compose down
13+
14+
pitchme_to_readme:
15+
#Example: FOLDER_NAME=classes/01class/git/ make pitchme_to_readme
16+
#Example: FOLDER_NAME=classes/01class/git/ BRANCH_NAME=MY_BRANCH make pitchme_to_readme
17+
bash scripts/pitchme_to_readme.sh

classes/01class/aws101/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- Cloud Benefits
99
- AWS Foundations
1010
- AWS Services
11-
- Labs and Exerciss
11+
- Labs and Exercises
1212

1313
### General Cloud Concepts
1414

@@ -18,7 +18,7 @@
1818
- Elastic services
1919
- Services can scale up and down so you can only pay what you need
2020
- Easy and cheap to test new technologies
21-
- Because you only pay for what you use, and during the time you use, you can run tests with new technologies for a weeka nd only pay for the resources onsumed during that week.
21+
- Because you only pay for what you use, and during the time you use, you can run tests with new technologies for a week and only pay for the resources consumed during that week.
2222
- Fast innovation pace
2323
- Being able to test without big investments, the feedback on tests are quicker and you can continuosly innovate
2424

@@ -30,7 +30,7 @@
3030
- Ephemeral Environments
3131
- Components are not changed/upgraded. They are fully replaced and nothing is expected to be lost
3232
- Automation
33-
- Automation is an important factor to be able to recreate environments faster and whitout human errors
33+
- Automation is an important factor to be able to recreate environments faster and without human errors
3434

3535
### Cloud Benefits
3636

@@ -105,7 +105,7 @@ Image from this [link](https://aws.amazon.com/about-aws/global-infrastructure/).
105105
- Block storage
106106
- https://aws.amazon.com/ebs/faqs/
107107
- EFS
108-
- Managed Elastic Filesystem(NFS)
108+
- Managed Elastic File System(NFS)
109109
- https://aws.amazon.com/efs/faq/
110110
#### Networking
111111
- VPC

classes/01class/exercises/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ For instructions on how to submit your work, [please check the main repository R
66
- [Account billing alarm (C01-E02)](/classes/01class/exercises/c01-e02/README.md)
77
- [First EC2 instance (C01-E03)](/classes/01class/exercises/c01-e03/README.md)
88
- [S3 (C01-E04)](/classes/01class/exercises/c01-e04/README.md)
9+
10+
- [Merging and Rebasing (c01-git01)](/classes/01class/exercises/c01-git01/README.md)
11+
- [Everyday questions (c01-git02)](/classes/01class/exercises/c01-git02/README.md)
12+
- [Big file (c01-git03)](/classes/01class/exercises/c01-git03/README.md)
13+
- [Secrets (c01-git04)](/classes/01class/exercises/c01-git04/README.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Merging and Rebasing (c01-git01)
2+
3+
1. Access https://learngitbranching.js.org/ (TIP: if you want to start over, just type `reset`)
4+
2. Merging exercise:
5+
1. type `level intro3`
6+
2. Submission: Include your commands on a file **c01-git01-1.txt**
7+
3. Rebasing exercise:
8+
1. type `level intro4`
9+
2. Submission: Include your commands on a file **c01-git01-2.txt**
10+
4. Revert and reset:
11+
1. type `level rampup4`
12+
2. Submission: Include your commands on a file **c01-git01-3.txt**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Everyday questions (c01-git02)
2+
3+
1. **file c01-git02-1.txt** - Is it possible to see the inner commit of squashed commit with `git rebase`?
4+
2. **file c01-git02-2.txt** - How to compare two different local repositories using `git diff`? How about remote ones, can you do the same?
5+
3. (Optional) Install [`ohmyzsh`](https://github.com/ohmyzsh/ohmyzsh) and activate the git plugin
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Big file (c01-git03)
2+
3+
Perform the following commands:
4+
1. Initialize a new git repository **locally** (you don't need to push it)
5+
2. Add a simple README.md text file (`touch README.md`) and commit it
6+
3. Check the commit with `git log`
7+
4. Check the size of the repository directory
8+
- On the parent, `du -sh .`
9+
5. Add a fairly big file `file.txt` (around 100MB)
10+
- `dd if=/dev/random of=file.txt count=1024 bs=10257`
11+
6. Add and commit it locally
12+
- `git add file.txt; git commit -m "Add big file"`
13+
7. Check the size of the repository directory again (take note of this)
14+
- On the parent, `du -sh .`
15+
8. Revert the commit that added the big file
16+
- use `git revert`, `git reset` or `git rebase`
17+
9. Check the size of the repository directory again (take note of this)
18+
- On the parent, `du -h`
19+
20+
**Questions**
21+
22+
Create a file **c01-git03-1.txt** answering the questions below. Include details and commands used.
23+
1. Did you notice any difference in the size of the repo before and after adding the big file?
24+
1. What is the reason for this problem?
25+
1. How do you remove something from Git history? Which commands would you use? What are the consequences?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Secrets (c01-git04)
2+
3+
Perform the following commands:
4+
1. In the same repository of the previous exercise:
5+
2. Add a file called `my_env.txt` that contains
6+
```
7+
SERVICE_NAME=account-management
8+
ENVIRONMENT=prod
9+
PASSWORD=pass1234
10+
```
11+
1. Commit it
12+
3. Check the commit with `git log`
13+
14+
**Questions**
15+
16+
Create a file **c01-git04-1.txt** answering the questions below. Include details and commands used.
17+
1. Let's suppose you remotely pushed your `my_env.txt` file. A colleague asks you to remove this information from Git. What's your colleague worried about?
18+
2. If you modify the file in your workspace, then push it, will it be enough? (It's not). Why?
19+
3. If you delete the file and push it, then create a new one with the rest of the information, is it enough? (It's not). Why?
20+
4. How to fix this? How do you remove something from Git history?
21+
5. Which commands would you use? What are the consequences for other developers?

classes/01class/git/PITCHME.md

+8-57
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ https://trunkbaseddevelopment.com/
176176
@snapend
177177

178178
@snap[south-west text-04]
179-
See also GitFlow (https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)
179+
[See also GitFlow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)
180180
@snapend
181181
---
182182

@@ -204,72 +204,23 @@ See also GitFlow (https://www.atlassian.com/git/tutorials/comparing-workflows/gi
204204

205205
---
206206

207-
@snap[north-west text-07]
208-
### Let's do it together
209-
@snapend
210-
211-
@snap[west text-06]
212-
213-
1. Access https://learngitbranching.js.org/
214-
1. merge - `level intro3`
215-
1. rebase - `level intro4`
216-
217-
@snapend
218-
219-
---
220-
221207
@snap[middlepoint text-07]
222208
## What is the problem of re-writing the history with **git rebase**?
223209
@snapend
224210

225211
---
226212

227-
@snap[north-west span-25 text-07]
228-
**Exercises**
229-
@snapend
230-
231-
@snap[west text-06]
232-
1. file ex_git01.txt - Is it possible to see the inner commit of squashed commit with `git rebase`?
233-
2. file ex_git02.txt - How to compare two different local repositories using `git diff`? How about remote ones, can you do the same?
234-
3. Install [`ohmyzsh`](https://github.com/ohmyzsh/ohmyzsh) and git plugin
235-
@snapend
236-
---
237-
238-
@snap[north-west text-07]
239-
**Exercise ex_git03** - Big file and secrets
240-
@snapend
241-
242-
@snap[west text-06]
243-
1. Initialize a new git repository locally
244-
2. Add a simple text file and commit
245-
- `echo "mypassword" > pwd.txt; git add pwd.txt; git commit -m "Add secret key file. I should not do it."`
246-
3. Check the commit with `git log`
247-
4. Check the size of the repository directory
248-
- On the parent, `du -sh .`
249-
5. Add a fairly big file `file.txt` (around 100MB)
250-
- `dd if=/dev/random of=file.txt count=1024 bs=10257`
251-
6. Add and commit it locally
252-
- `git add file.txt; git commit -m "Add big file"`
253-
7. Check the size of the repository directory again (take note of this)
254-
- On the parent, `du -sh .`
255-
8. Revert the commit that added the big file
256-
- use `git revert`, `git reset` or `git rebase`
257-
9. Check the size of the repository directory again (take note of this)
258-
- On the parent, `du -h`
259-
@snapend
260-
261-
---
262-
263213
@snap[north-west text-07]
264-
**Exercise ex_git03** - Big file and secrets
214+
### Let's do it together - Exercise
265215
@snapend
266216

267217
@snap[west text-06]
268-
- Did you notice any difference in the size of the repo before and after adding the big file
269-
- What is causing this problem?
270-
- Let's suppose you remotely pushed your `pwd.txt` file. If you delete it and push it, is it enough? (It's not). Why?
271-
- How do you solve it, i.e. how do you remove something from Git history? What are the consequences?
272-
218+
**Merging and Rebasing**
219+
1. Access https://learngitbranching.js.org/
220+
2. Merging exercise:
221+
1. type `level intro3`
222+
3. Rebasing exercise:
223+
1. type `level intro4`
273224
@snapend
274225

275226
---

classes/01class/git/README.md

+165-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,165 @@
1-
## Presentation
2-
https://gitpitch.com/devopsacademyau/academy?p=/classes/01class/git#/
1+
#### Presentation URL: https://gitpitch.com/devopsacademyau/academy?p=classes/01class/git/
2+
3+
# Let's Get **Started** with Git
4+
5+
---
6+
### Versioning: The "old way"
7+
8+
- Pessimistic locking, code duplication
9+
- Local versioning -> Copy and paste (Let's duplicate!)
10+
- Version overwriting (Who deleted my version!?)
11+
- Locked file (Can you please release file customers.xls, please!?)
12+
- Are there other problems?
13+
14+
15+
---
16+
### What is Git?
17+
18+
- Created by Linus Torvalds in 2005 for development of the Linux kernel
19+
- Git is a distributed VCS
20+
- Centralized vs Distributed VCS?
21+
- Optimistic vs Pessimistic locking?
22+
23+
24+
![IMAGE](assets/git.0.jpg)
25+
26+
---
27+
28+
### Centralised vs Distributed VCS
29+
30+
- Centralised:
31+
- Centralised master version
32+
- Code Check outs (one developer is allowed to work on that part of the code at any one time.)
33+
- Locking controlled by the server
34+
- Release records version numbers of all elements
35+
- Distributed:
36+
- Entire history of changes cloned by developers
37+
- No locking
38+
- Changes modify history (append or rewrite)
39+
- Release is a history of changes
40+
41+
---
42+
43+
### Optimistic Locking
44+
45+
![IMAGE](assets/OptimisticSketch.gif)
46+
47+
48+
---
49+
50+
So, how git achieves optimistic locking so developers can work in parallel in the same file?
51+
52+
---
53+
54+
### Git Storage
55+
![IMAGE](assets/git_storage.png)
56+
57+
58+
---
59+
60+
### Git Main Commands
61+
62+
- start a working area (see also: git help tutorial)
63+
- **clone** Clone a repository into a new directory
64+
- **init** Create an empty Git repository or reinitialize an existing one
65+
66+
- work on the current change (see also: git help everyday)
67+
- **add** Add file contents to the index
68+
- **mv** Move or rename a file, a directory, or a symlink
69+
- **reset** Reset current HEAD to the specified state
70+
- **rm** Remove files from the working tree and from the index
71+
72+
- examine the history and state (see also: git help revisions)
73+
- **bisect** Use binary search to find the commit that introduced a bug
74+
- **grep** Print lines matching a pattern
75+
- **log** Show commit logs
76+
- **show** Show various types of objects
77+
- **status** Show the working tree status
78+
79+
---
80+
81+
### Git Main Commands (more)
82+
83+
- grow, mark and tweak your common history
84+
- **branch** List, create, or delete branches
85+
- **checkout** Switch branches or restore working tree files
86+
- **commit** Record changes to the repository
87+
- **diff** Show changes between commits, commit and working tree, etc
88+
- **merge** Join two or more development histories together
89+
- **rebase** Reapply commits on top of another base tip
90+
- **tag** Create, list, delete or verify a tag object signed with GPG
91+
92+
- collaborate (see also: git help workflows)
93+
- **fetch** Download objects and refs from another repository
94+
- **pull** Fetch from and integrate with another repository or a local branch
95+
- **push** Update remote refs along with associated objects
96+
97+
98+
---
99+
100+
### Let's do it together
101+
Let's add a folder to hold exercises for classes
102+
103+
1. Check README.md in the root for instructions.
104+
2. Add, commit and push it to your remote dev branch :tada:
105+
3. Create a Pull Request (PR)
106+
107+
108+
---
109+
110+
### Checking in code can get complex (quickly!)
111+
![IMAGE](assets/merge_hell.png)
112+
113+
How can we have a standard approach to work as one team?
114+
115+
---
116+
### A solution: Trunk based development
117+
118+
Short lived branches simplify a lot of things!
119+
https://trunkbaseddevelopment.com/
120+
121+
[See also GitFlow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow)
122+
---
123+
124+
![IMAGE](assets/merge_vs_rebase.jpg)
125+
126+
---
127+
128+
### Merging vs Rebasing
129+
130+
`git checkout feature`
131+
`git merge master`
132+
![IMAGE](assets/merge.png)
133+
134+
`git checkout feature`
135+
`git rebase master`
136+
![IMAGE](assets/rebase.png)
137+
138+
---
139+
140+
## What is the problem of re-writing the history with **git rebase**?
141+
142+
---
143+
144+
### Let's do it together - Exercise
145+
146+
**Merging and Rebasing**
147+
1. Access https://learngitbranching.js.org/
148+
2. Merging exercise:
149+
1. type `level intro3`
150+
3. Rebasing exercise:
151+
1. type `level intro4`
152+
153+
---
154+
155+
**OMG, I don't know what I did!**
156+
157+
https://ohshitgit.com/
158+
159+
---
160+
161+
### References
162+
163+
1. https://martinfowler.com/eaaCatalog/optimisticOfflineLock.html
164+
1. https://www.teamstudio.com/blog/distributed-vs-centralized-version-control-systems-for-lotus-notes
165+
1. https://www.atlassian.com/git/tutorials/merging-vs-rebasing

0 commit comments

Comments
 (0)