diff --git a/levels/00-empty/description b/levels/00-empty/description deleted file mode 100644 index 0e18f97..0000000 --- a/levels/00-empty/description +++ /dev/null @@ -1 +0,0 @@ -This is an empty level without any winning condition - you can use it as a playground! diff --git a/levels/basics/congrats b/levels/basics/congrats new file mode 100644 index 0000000..5cf8a73 --- /dev/null +++ b/levels/basics/congrats @@ -0,0 +1,3 @@ +Omnomnom! + +For technical reasons, you can't use `cd` in this prototype yet. But there won't be a lot of interaction with the file system anyways. :) diff --git a/levels/basics/description b/levels/basics/description new file mode 100644 index 0000000..fb73e9a --- /dev/null +++ b/levels/basics/description @@ -0,0 +1,8 @@ +For this prototype, we assume you have some experience with the command line. Here are some commands that will be useful: + +- ls +- echo content > file +- cat file +- mkdir dir + +Find the riddle in your current directory and put the answer into the file "answer"! diff --git a/levels/basics/start b/levels/basics/start new file mode 100644 index 0000000..5e68d49 --- /dev/null +++ b/levels/basics/start @@ -0,0 +1,3 @@ +mkdir riddle +echo "ppl p" > riddle/consonants +echo "ae ie" > riddle/vowels diff --git a/levels/basics/win b/levels/basics/win new file mode 100644 index 0000000..eeb81a9 --- /dev/null +++ b/levels/basics/win @@ -0,0 +1 @@ +cat answer | grep -i "apple \\?pie" diff --git a/levels/blob-create/congrats b/levels/blob-create/congrats new file mode 100644 index 0000000..90262a9 --- /dev/null +++ b/levels/blob-create/congrats @@ -0,0 +1,3 @@ +Tip: You can also use a command like this to create a blob in a single line: + + echo "awesome content" | git hash-object -w --stdin diff --git a/levels/blob-create/description b/levels/blob-create/description index 15437bd..11a971e 100644 --- a/levels/blob-create/description +++ b/levels/blob-create/description @@ -4,12 +4,8 @@ There are four types of objects: blobs, trees, commits, and tags. The simplest t Let's create some blobs! To do that, create a file with the desired content, and then use - $ git hash-object -w + git hash-object -w The flag -w means "write", and tells Git to actually write the new blob to the disk. Create three new blobs! - -Tip: you can also use a command like this to create a blob in a single line: - - $ echo "awesome content" | git hash-object -w --stdin diff --git a/levels/blob-remove/congrats b/levels/blob-remove/congrats new file mode 100644 index 0000000..0e6bd7b --- /dev/null +++ b/levels/blob-remove/congrats @@ -0,0 +1,3 @@ +Generally, `git prune` will be useful if you want to clean up some objects you made. + +Alternatively, you can also click the "Reload" button to restart a level. diff --git a/levels/blob-remove/description b/levels/blob-remove/description index a2fbc3b..a819ad1 100644 --- a/levels/blob-remove/description +++ b/levels/blob-remove/description @@ -1,5 +1,5 @@ -There's a simple command to remove all blobs that are not connected to anything: +There's a simple command to remove all objects that are not referenced by anything: - $ git prune + git prune Remove all blobs in this repository. diff --git a/levels/commit-create/description b/levels/commit-create/description index 1cdd206..fff32b3 100644 --- a/levels/commit-create/description +++ b/levels/commit-create/description @@ -1,9 +1,9 @@ -So a tree describes the state of a directory structure at a specific point in time. +So a tree describes a directory structure at a specific point in time. It would be nice if we could remember when that state existed, and who authored it, right? Enter: commits. They are objects that point to a tree and contain some additional metadata. You can create a commit using - $ git commit-tree -m "Description of your commit" + git commit-tree -m "Description of your commit" Make a commit from the tree in this repository! diff --git a/levels/commit-parents/description b/levels/commit-parents/description index e52de96..e36bce7 100644 --- a/levels/commit-parents/description +++ b/levels/commit-parents/description @@ -1,7 +1,7 @@ When using the commit-tree command, you can optionally specify a parent: - $ git commit-tree -m "Description" -p + git commit-tree -m "Description" -p Make a string of three commits! -Hint: What would be the easiest way to get a tree object? +Hint: You'll need a tree object. What could be the easiest way to obtain one? diff --git a/levels/conflict/description b/levels/conflict/description index 8ff892a..af3bdc7 100644 --- a/levels/conflict/description +++ b/levels/conflict/description @@ -1,3 +1,5 @@ +(This is not a real puzzle yet.) + Try merging the two branches together! git merge diff --git a/levels/conflict/goal b/levels/conflict/goal new file mode 100644 index 0000000..edeb2fa --- /dev/null +++ b/levels/conflict/goal @@ -0,0 +1,5 @@ +git merge alternative +echo blue-green > bikeshed_color +git add . +git commit -m "Merge" +git prune diff --git a/levels/index-add/congrats b/levels/index-add/congrats new file mode 100644 index 0000000..bc6af39 --- /dev/null +++ b/levels/index-add/congrats @@ -0,0 +1,7 @@ +There's another way to add an entry to the index directly: + + git update-index --add --cacheinfo ,, + +The first three numbers of the mode describe the type of the entry, "100" is a regular file. + +The second three number describe the permissions. Only "644" (non-executable) and "755" (executable) are supported. diff --git a/levels/index-add/description b/levels/index-add/description index 197f750..63b9fb9 100644 --- a/levels/index-add/description +++ b/levels/index-add/description @@ -1,10 +1,10 @@ Blobs usually represent the content of a file. But on their own, they don't have any metadata, not even a name! -Git has a very powerful concept to store metadata related to blobs: the index! It's a list that relates blobs to filenames and permissions. +Git has a very powerful concept to store metadata related to blobs: the index! It's a list that relates blobs to filenames and access permissions. -Even though it is possible to add an entry directly to the index, it's much more convenient to do it via an existing file: +The most convenient option to add an entry to the index is via an existing file: - $ echo "my content" > file - $ git update-index --add file + echo "my content" > file + git update-index --add file Add three entries to the index! For a bonus challenge: can you add a file that is inside of a directory, like "directory/file"? diff --git a/levels/index-remove/description b/levels/index-remove/description index 3ba8f7b..51643cc 100644 --- a/levels/index-remove/description +++ b/levels/index-remove/description @@ -1,5 +1,5 @@ To remove an entry from the index, use a command like this: - $ git update-index --force-remove + git update-index --force-remove Remove all entries from the index! diff --git a/levels/index-update/description b/levels/index-update/description index 7ad098b..cae3bd3 100644 --- a/levels/index-update/description +++ b/levels/index-update/description @@ -2,7 +2,7 @@ Instead of removing an entry from the index and adding one with the same name, y Put the content you want in a file with a matching name, and then run - $ git update-index + git update-index This will create a new blob, and update the hash of the entry to that blob. diff --git a/levels/index-update/win b/levels/index-update/win index 43787fa..2eade0a 100644 --- a/levels/index-update/win +++ b/levels/index-update/win @@ -1 +1,2 @@ -test "$(git ls-files | wc -l)" -eq 0 +# This is not really a good test for the winning condition... +test "$(git ls-files -s | git hash-object --stdin)" != "10c4b28623e7e44e09f5a596450a50ab7ac31fbe" -a "$(git ls-files | wc -l)" -eq 3 diff --git a/levels/puzzle-trees-all-the-way-down/description b/levels/puzzle-trees-all-the-way-down/description index f38ca57..ddbe5b1 100644 --- a/levels/puzzle-trees-all-the-way-down/description +++ b/levels/puzzle-trees-all-the-way-down/description @@ -1,3 +1,3 @@ -Construct a chain of three trees. +Construct a chain of three trees, which don't point to anything else. This is hard! The `git mktree` command might be useful. diff --git a/levels/ref-move/win b/levels/ref-move/win index 14ed974..e792ccf 100644 --- a/levels/ref-move/win +++ b/levels/ref-move/win @@ -1 +1 @@ -test "$(git show-ref -s | uniq)" = "c7863f72467ed8dd44f4b8ffdb8b57ca7d91dc9e" +test "$(git show-ref -s | sort -u)" = "c7863f72467ed8dd44f4b8ffdb8b57ca7d91dc9e" diff --git a/levels/ref-remove/description b/levels/ref-remove/description index a8fd88a..d222012 100644 --- a/levels/ref-remove/description +++ b/levels/ref-remove/description @@ -1,5 +1,5 @@ -To delete a ref, use +And finally, to delete a ref, use git update-ref -d refs/ -Delete all refs! :P +Delete all refs! :P (Well, except for HEAD. HEAD is special.) diff --git a/levels/symref-no-deref/congrats b/levels/symref-no-deref/congrats new file mode 100644 index 0000000..fa78278 --- /dev/null +++ b/levels/symref-no-deref/congrats @@ -0,0 +1,13 @@ +Whew, we've covered a lot of things: Blobs! The index! Trees! Commits! Refs! + +You now know about almost everything about how Git repositories look like on the inside! We think that's pretty cool! :) + +Everything else is just convention and high-level commands that make interacting with the objects more convenient. + +We haven't covered: + +- tag objects (they are the fourth object type - a bit like refs with a description and an author) +- configuration (allows you to specify remote repositories, for example) +- working with local files (which is, uh, arguably pretty important :P) + +Thanks for playing! You're welcome to check out the "puzzle" levels in the dropdown, some of them are more advanced! diff --git a/levels/tree-create/congrats b/levels/tree-create/congrats new file mode 100644 index 0000000..89498e5 --- /dev/null +++ b/levels/tree-create/congrats @@ -0,0 +1,3 @@ +Nice! + +Can you make a different tree? Modify the index, then call `git write-tree` again! diff --git a/levels/tree-create/description b/levels/tree-create/description index a5b96ce..c796fb3 100644 --- a/levels/tree-create/description +++ b/levels/tree-create/description @@ -2,6 +2,6 @@ After carefully building the index we want, it would be nice to save a permanent This is what the second type of objects is for: trees! You can convert the index into a tree using - $ git write-tree + git write-tree Try it! :) diff --git a/levels/tree-read/description b/levels/tree-read/description index b4683c2..f1764a7 100644 --- a/levels/tree-read/description +++ b/levels/tree-read/description @@ -1,5 +1,5 @@ As soon as you have some tree objects, you can always read them and set the index exactly to their content! Unsurprisingly, the command is called - $ git read-tree + git read-tree -Try switching between the trees in this repository! +Try reading some of the trees in this repository into the index! diff --git a/levels/welcome/congrats b/levels/welcome/congrats new file mode 100644 index 0000000..3fff8eb --- /dev/null +++ b/levels/welcome/congrats @@ -0,0 +1,7 @@ +Well done! + +An empty Git repository is... well, quite empty. The only thing that always exists is a reference called "HEAD" - we'll learn what that is later! + +But first, let's look at some basics! + +(Click "Next Level" as soon as you're ready!) diff --git a/levels/welcome/description b/levels/welcome/description index 6ab0432..4192bad 100644 --- a/levels/welcome/description +++ b/levels/welcome/description @@ -1,7 +1,7 @@ -To the left, you see an empty Git repository! +This is prototype #1 for the Git learning game by @bleeptrack and @blinry. Thanks for checking it out! <3 -The only thing that's always there is the HEAD reference - we'll look at what that is later. +You can interact with the repository on the right by typing Bash commands in the terminal below! -You can drag and drop all nodes on the left, and reorder them how you want! +Let's get started by initializing an empty Git repository in the current directory by typing: -You can enter Bash commands in the line at the bottom. + git init diff --git a/levels/welcome/goal b/levels/welcome/goal new file mode 100644 index 0000000..e9be2cf --- /dev/null +++ b/levels/welcome/goal @@ -0,0 +1 @@ +git init diff --git a/levels/welcome/start b/levels/welcome/start new file mode 100644 index 0000000..4405c9e --- /dev/null +++ b/levels/welcome/start @@ -0,0 +1 @@ +rm -rf .git diff --git a/levels/welcome/win b/levels/welcome/win new file mode 100644 index 0000000..714ec2c --- /dev/null +++ b/levels/welcome/win @@ -0,0 +1 @@ +test -d .git