-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Level: The Truth #277
Open
benthayer
wants to merge
5
commits into
main
Choose a base branch
from
truth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Level: The Truth #277
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a3c9704
Added The Truth level
benthayer 9c502a0
Added content for The Truth
benthayer 45a1031
Updated The Truth levels per review
benthayer dceca84
Get commits from detached head in level tree
benthayer f68c1c3
Detach head and check for new branch created
benthayer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'1': | ||
message: This | ||
add-files: | ||
This.txt: | ||
- "Hello, this file doesn't do anything." | ||
'2': | ||
message: is | ||
add-files: | ||
is.txt: | ||
- "Hello, this file doesn't do anything." | ||
'3': | ||
message: an | ||
add-files: | ||
an.txt: | ||
- "Hello, this file doesn't do anything." | ||
'4': | ||
message: easy | ||
add-files: | ||
easy.txt: | ||
- "Hello, this file doesn't do anything." | ||
'5': | ||
message: level | ||
add-files: | ||
level.txt: | ||
- "Hello, this file doesn't do anything." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
There's something you need to know about... | ||
>>> | ||
The truth is... | ||
>>> | ||
What you did with "git rebase -i"... | ||
>>> | ||
Can be done by... | ||
>>> | ||
Detatching your head! Eek! | ||
>>> | ||
Let me clarify, I'm actually talking about your HEAD. | ||
>>> | ||
HEAD is used to refer to the commit or branch that is currently checked out. | ||
This basically means that when you're on branch "master", HEAD resolves to "master", which itself resolves to a commit. | ||
>>> | ||
This is important because when you're in a 'detached HEAD' state, cherry-picking still works the same way, and you can do exactly what you just did in the last level. | ||
>>> | ||
Normally, HEAD points to the branch that you have checked out, so it refers to whichever commit the branch does, even if there is a new commit! | ||
For example, if you have bugFix checked out, then when bugFix is updated, HEAD is updated as well, just like this: | ||
|
||
// HEAD points to bugFix. | ||
C1 | ||
^ bugFix < HEAD | ||
|
||
// A new commit (C2) caused bugFix to move to C2, HEAD effectively points to C2 | ||
C1 ---- C2 | ||
^ bugFix < HEAD | ||
|
||
For us, since no branches point to the first commit, we can't check it out while staying on a branch. | ||
>>> | ||
What if we have HEAD to point at a commit rather than a branch? | ||
(e.g., HEAD > C1 instead of HEAD > bugFix > C1) | ||
>>> | ||
In comes the concept of the 'detached HEAD' state. Simply use "git checkout <commit_hash>" to modify HEAD so that it points to the commit instead of the branch. | ||
>>> | ||
As you've seen, a commit hash is a unique identifier for a commit. | ||
Use "git log" or "git gud status" to see the commit tree and to look for the hashes. | ||
>>> | ||
The hashes look something like: "d6ba740". | ||
The full commit hash is 40 characters long, and every one is unique. | ||
>>> | ||
In general, if you only have a few commits, even just the first few characters of the commit hash are going to be unique, so you can use as few as the first four characters to refer to the commit. | ||
Using the example has above "git checkout d6ba" will detach the HEAD so it refers to the commit with the hash "d6ba740" | ||
>>> | ||
Finally, to beat this level, you're going to need to check out the first commit (detaching HEAD) then cherry-pick the rest of the commits so they are in the right order. | ||
Finish the job by making a new branch with the re-ordered commits. | ||
It can be named anything, but don't check it out so we know you detached your HEAD! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Just like last level, make the log messages form the sentence "This is an easy level" | ||
This time, instead of rebasing, detach HEAD using git checkout then use git cherry-pick. | ||
Save your changes on a new branch named whatever you want, but don't check it out. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Commits here are out of order | ||
# When the commits are in the correct order, they read "This is an easy level" | ||
1 | ||
4 | ||
3 | ||
2 | ||
5 (master) | ||
master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
git checkout master~4 | ||
git cherry-pick master~1 | ||
git cherry-pick master~2 | ||
git cherry-pick master~3 | ||
git cherry-pick master | ||
git branch random-branch-name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# The commits on master and in setup.spec are out of order | ||
1 | ||
4 | ||
3 | ||
2 | ||
5 (master) | ||
2' : 1 | ||
3' | ||
4' | ||
5' | ||
5' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also mention
git gud show tree