Compare commits
5 Commits
3a4fe8ce9e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c20041efde | ||
|
|
84ed357feb | ||
|
|
9659d82d2a | ||
|
|
dbba2da5f2 | ||
|
|
1d0003bb70 |
@@ -52,10 +52,13 @@ First, see what commits are on the development branch:
|
|||||||
```pwsh
|
```pwsh
|
||||||
cd challenge
|
cd challenge
|
||||||
|
|
||||||
# View all commits on development branch
|
# First let's see what files are in the current branch and notice that there is a file security.py
|
||||||
git log --oneline development
|
ls
|
||||||
|
|
||||||
# View the full commit graph
|
# View all commits on development branch
|
||||||
|
git log --oneline --graph
|
||||||
|
|
||||||
|
# View the full commit graph for all branches
|
||||||
git log --oneline --graph --all
|
git log --oneline --graph --all
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -87,6 +90,9 @@ git switch main
|
|||||||
|
|
||||||
# Verify you're on main
|
# Verify you're on main
|
||||||
git branch
|
git branch
|
||||||
|
|
||||||
|
# See what files exist. Notice that we no longer have a security.py file
|
||||||
|
ls
|
||||||
```
|
```
|
||||||
|
|
||||||
The `*` should be next to `main`.
|
The `*` should be next to `main`.
|
||||||
@@ -96,8 +102,6 @@ The `*` should be next to `main`.
|
|||||||
# See main's commits
|
# See main's commits
|
||||||
git log --oneline
|
git log --oneline
|
||||||
|
|
||||||
# See what files exist
|
|
||||||
ls
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Main should only have the initial app and README - no bug fixes yet, no experimental features.
|
Main should only have the initial app and README - no bug fixes yet, no experimental features.
|
||||||
@@ -110,26 +114,26 @@ Now copy the bug fix commits from development to main:
|
|||||||
- Look for a commit message like "Fix security vulnerability in input validation"
|
- Look for a commit message like "Fix security vulnerability in input validation"
|
||||||
- Note its hash (first 7 characters)
|
- Note its hash (first 7 characters)
|
||||||
|
|
||||||
2. First let's just check whether or not we have the `security.py` and `cache.py` file available by running `ls` in the challenge directory or check the file explorer in your VSCode
|
2. Cherry-pick the security fix:
|
||||||
|
|
||||||
3. Cherry-pick the security fix:
|
|
||||||
```pwsh
|
```pwsh
|
||||||
git cherry-pick <security-fix-hash>
|
git cherry-pick <security-fix-hash>
|
||||||
|
ls # we now have the security.py file!
|
||||||
|
|
||||||
# Example if the hash is abc1234:
|
# Example if the hash is abc1234:
|
||||||
# git cherry-pick abc1234
|
# git cherry-pick abc1234
|
||||||
```
|
```
|
||||||
4. Verify it worked: Check that security.py, with `ls` or check your file explorer in VSCode, now exists and check that the commit has been added to the main branch with `git log --oneline --graph --all`
|
3. Verify it worked: Check that security.py, with `ls` or check your file explorer in VSCode, now exists and check that the commit has been added to the main branch with `git log --oneline --graph --all`
|
||||||
5. Find the performance fix commit hash
|
4. Find the performance fix commit hash
|
||||||
- Look for "Fix performance issue with data caching"
|
- Look for "Fix performance issue with data caching"
|
||||||
- Note its hash
|
- Note its hash
|
||||||
|
|
||||||
6. Cherry-pick the performance fix:
|
5. Cherry-pick the performance fix:
|
||||||
```pwsh
|
```pwsh
|
||||||
git cherry-pick <performance-fix-hash>
|
git cherry-pick <performance-fix-hash>
|
||||||
|
ls # we now have the cache.py file!
|
||||||
```
|
```
|
||||||
|
|
||||||
7. Verify both fixes are now on main:
|
6. Verify both fixes are now on main:
|
||||||
```pwsh
|
```pwsh
|
||||||
# You should see both security.py and cache.py
|
# You should see both security.py and cache.py
|
||||||
ls
|
ls
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ Suddenly, your teammate reports a **critical security bug** in production! You n
|
|||||||
|
|
||||||
2. **Check your current status:**
|
2. **Check your current status:**
|
||||||
```pwsh
|
```pwsh
|
||||||
git status
|
git status # See which files are changed
|
||||||
|
git diff # See all the changes in a diffview
|
||||||
```
|
```
|
||||||
You should see modified `login.py` (uncommitted changes)
|
You should see modified `login.py` (uncommitted changes)
|
||||||
|
|
||||||
@@ -116,15 +117,12 @@ Suddenly, your teammate reports a **critical security bug** in production! You n
|
|||||||
```
|
```
|
||||||
|
|
||||||
6. **Open app.py and find the bug:**
|
6. **Open app.py and find the bug:**
|
||||||
```pwsh
|
|
||||||
cat app.py
|
|
||||||
```
|
|
||||||
Look for the comment "# BUG: This allows unauthenticated access!"
|
Look for the comment "# BUG: This allows unauthenticated access!"
|
||||||
|
|
||||||
7. **Fix the bug** by editing app.py:
|
7. **Fix the bug** by editing app.py:
|
||||||
- Remove the buggy comment line
|
- Remove the buggy comment line
|
||||||
- You can leave the implementation as-is or improve it
|
- You can leave the implementation as-is or improve it
|
||||||
- The important thing is removing the comment that says "allows unauthenticated access"
|
- The important thing is removing the comment that says "BUG: This allows unauthenticated access"
|
||||||
|
|
||||||
8. **Commit the fix:**
|
8. **Commit the fix:**
|
||||||
```pwsh
|
```pwsh
|
||||||
@@ -143,10 +141,8 @@ Suddenly, your teammate reports a **critical security bug** in production! You n
|
|||||||
```
|
```
|
||||||
This applies the stash and removes it from the stash stack
|
This applies the stash and removes it from the stash stack
|
||||||
|
|
||||||
11. **Complete the TODOs in login.py:**
|
11. **Remove all the TODOs in login.py:**
|
||||||
- Open login.py in your editor
|
- Open login.py in your editor
|
||||||
- Complete the login method (verify password and return session)
|
|
||||||
- Add a logout method
|
|
||||||
- Remove all TODO comments
|
- Remove all TODO comments
|
||||||
|
|
||||||
12. **Commit your completed feature:**
|
12. **Commit your completed feature:**
|
||||||
@@ -194,10 +190,7 @@ git stash pop
|
|||||||
git stash apply
|
git stash apply
|
||||||
|
|
||||||
# Apply a specific stash
|
# Apply a specific stash
|
||||||
git stash apply stash@{1}
|
git stash apply "stash@{1}"
|
||||||
|
|
||||||
# Apply a specific stash by number
|
|
||||||
git stash apply 1
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Managing Stashes
|
### Managing Stashes
|
||||||
@@ -207,7 +200,7 @@ git stash apply 1
|
|||||||
git stash drop
|
git stash drop
|
||||||
|
|
||||||
# Drop a specific stash
|
# Drop a specific stash
|
||||||
git stash drop stash@{1}
|
git stash drop "stash@{1}"
|
||||||
|
|
||||||
# Clear all stashes
|
# Clear all stashes
|
||||||
git stash clear
|
git stash clear
|
||||||
@@ -293,10 +286,10 @@ git stash pop
|
|||||||
git stash list
|
git stash list
|
||||||
|
|
||||||
# Show summary of what changed
|
# Show summary of what changed
|
||||||
git stash show stash@{0}
|
git stash show "stash@{0}"
|
||||||
|
|
||||||
# Show full diff
|
# Show full diff
|
||||||
git stash show -p stash@{0}
|
git stash show -p "stash@{0}"
|
||||||
```
|
```
|
||||||
|
|
||||||
### "Stash conflicts when I apply"
|
### "Stash conflicts when I apply"
|
||||||
|
|||||||
9
06-FAQ.md
Normal file
9
06-FAQ.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Questions
|
||||||
|
|
||||||
|
## Is it possible to recover lost branches or commits?
|
||||||
|
|
||||||
|
Yes it is, however this is dependent on whether or not git has done an internal garbage collection which there usually is a retention period of 30 days.
|
||||||
|
|
||||||
|
**Beware** this is advanced territory and is usually only relevant when you've messed up with a `git reset` or a deletion of a branch
|
||||||
|
|
||||||
|
To read more, you can read the documentation here <https://git-scm.com/docs/git-reflog>
|
||||||
Reference in New Issue
Block a user