Completing The GitGame
This semester has been pretty sucky, till now. My research topics are a little vague and uncertain. The projects are fun and stuff, but the “Procrastination” is up to a whole new level, oh yeah. Spent a whole day making a PHDComic scraper, lol. Well, but that was fun too. :D
Anyways, there’s this Repository going really-really strong in the GitHub trending section: Git-Game, and boy-oh-boy did i wanna finish that thing. You know, it isn’t much but at least it has a nice puzzle-quizy feel to it. So after keeping the game open in my Iceweasel tab for about 3-4 days, i finally completed it about 3 days ago, and it’s much-much better than all the other Git-Learning games out there, and to mark that milestone, i gotta write down the process for the game. Here goes nothing..
The Game Process..
tl;dr: If you’re reading this, you’ll be much better off checking out the original Game on GitHub.. “Spoiler Alert”
So the repository README tells you to clone the GitHub repository into your working directory. I’m assuming that all of you have “git” and other dependencies installed on your system. If not, please do check out the guides present online, as they are much better than me trying to write here what it means. Now,
git clone "https://github.com/hgarc014/git-game"
This creates a proper clone of the repository in your current working directory. Now, the README.md file contains all the information and mentions, explicitly, the fact that all future “hints” will be given in the README files. The first exercise/hint says:
You should always check the README.md file for your next clue!
Your first task is to checkout the commit whose commit message is the answer to this question:
When a programmer is born, what is the first thing he/she learns to say?
Now the answer is obviously “Hello World”, or some form of it, so this was pretty straight-forward. All we need is the log of all the commits, so that we can go to a previous commit.
$ git log
commit 25bfa08b92de73c9ecfe46a35a537684d26d9171
Author: Henry Garcia
Date: Tue Jan 13 17:32:30 2015 -0800
added information for people that don't know git
commit 27e9786d8a71d73c06f46593293b3865015596ac
Merge: bc9641f 3893960
Author: Henry Garcia
Date: Thu Jan 8 11:28:39 2015 -0800
Merge pull request #6 from riqpe/master
Corrected description of difficulty progression
commit 3893960db081abcd2a0944dd692a1d2c16980d46
Author: riqpe
Date: Thu Jan 8 14:31:44 2015 +0100
Corrected description of difficulty progression
commit bc9641f9970b073d2f39a8b6414dc5c8949690c5
Author: Henry Garcia
Date: Fri Dec 19 09:29:14 2014 -0800
updated README
commit 9b9380ba22cd3f1d0974abeea9738fa60ef96a2e
Author: Henry Garcia
Date: Fri Dec 19 09:24:33 2014 -0800
Hello World!
commit 8cafb7c87b129686da362b14c3f3c750c1fe4bf5
Author: Henry Garcia
Date: Sun Nov 30 18:29:35 2014 -0800
Initial commit
Now, the commit 9b9380ba22cd3f1d0974abeea9738fa60ef96a2e has the entry “Hello World!”. So, let’s just see what it gets us.
$ git checkout 9b9380ba22cd3f1d0974abeea9738fa60ef96a2e
Note: checking out '9b9380ba22cd3f1d0974abeea9738fa60ef96a2e'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
HEAD is now at 9b9380b... Hello World!
Well, that was lucky :) At least we got something. Now, time to check the new README.md file obtained..
$ cat README.md
git-game
========
Hello World!
It looks like you have some knowledge about traversing commits!
Well, let's get this party started!
We want to get to a branch whose name is the answer to this riddle:
I am a creature that is smaller than man, but many times more in number.
In code, my appearance can be subtle and no matter where I am found, I am unwanted.
What am I?
Voila, there’s the second clue. Now, i won’t lie. The “I am unwanted.” part of the clue just kept making me think that the answer must be “comment”. There was this awesome thread on StackOverflow about some of the most interesting comments people have come across over the years. There was this particular “insightful” answer:
//sometimes I believe compiler ignores all my comments
Keeping that in mind, i just kept thinking that “comment” would be the answer. But, the “I am a creature that is smaller than man, but many times more in number” kept throwing me off-base. Also, well, “comment” was not giving me a right answer, lol :P
So, naturally it had to be something else. It took me a lot of time to finally realize that the answer is “bug”. Just plain simple “bug”. :D I was writing down code for my Software Engineering class project and BOOM, it just jumped out at me from my Python interpreter, the thing i hate the most: BUGS.
$ git checkout bug
Previous HEAD position was 9b9380b... Hello World!
Branch bug set up to track remote branch bug from origin.
Switched to a new branch 'bug'
Now checking out the new README.md file obtained.
$ cat README.md
git-game
========
Congratulations, it looks like you found the "bug."
When you work with other programmers on the same project, bugs are bound to appear.
One way to create bugs is by changing code that you did not write without understanding what the code is doing.
Sometimes we like to blame others for introducing bugs in our code.
Think you can find out who introduced a bug into our file cool.cpp?
We think he had something to do with the development of git.
And from what we hear he also made a branch under his name.
Checkout to that branch after you find out who the culprit is.
~$ ls
cool.cpp LICENSE README.md remember
Now, do not, and just DO-NOT, open and try to see the “remember” file. It contains a LOT of random keywords and strings meaning nothing. There is a C++ file in the directory and the README tells us that something or someone has messed with the source code of the file. It also tells us that someone who had something to do with git’s development might just be responsible for it. It has to be something to do with Linus Torvalds, ‘cause he did develop the git version control. So, we check who has worked on this particular branch.
$ git log --graph
* commit d4827d27af0af2fce8575230486efc3d89513d9d
| Author: Henry Garcia
| updated remember
|
* commit 3922a6d86ec4b0ea00c7b7414e96ffd3b2f65f45
| Author: LinusTorvalds2014
| update
|
* commit ce59bbfd5b04ece742e799c68bf94af2c46281d4
| Author: Henry Garcia
| added cool.cpp and updated README
|
* commit 8cafb7c87b129686da362b14c3f3c750c1fe4bf5
Author: Henry Garcia
Initial commit
And there it is. A commit by someone called LinusTorvalds2014. This is what we want. Now to see who has worked on the cool.cpp source code file. The hint is actually in the word “blame” in the README, since there is an existing git command called blame that can be used to find out who has ever changed anything on a file. So:
~$ git blame cool.cpp
ce59bbfd (Henry Garcia 2014-12-08 18:22:35 -0800 1) #include
ce59bbfd (Henry Garcia 2014-12-08 18:22:35 -0800 3) using namespace std;
ce59bbfd (Henry Garcia 2014-12-08 18:22:35 -0800 5) int main()
ce59bbfd (Henry Garcia 2014-12-08 18:22:35 -0800 6) {
ce59bbfd (Henry Garcia 2014-12-08 18:22:35 -0800 7) string mesg = "Hello! Who are you?";
ce59bbfd (Henry Garcia 2014-12-08 18:22:35 -0800 8) string input;
ce59bbfd (Henry Garcia 2014-12-08 18:22:35 -0800 9) cout << mesg << endl;
ce59bbfd (Henry Garcia 2014-12-08 18:22:35 -0800 10) cin >> input;
3922a6d8 (LinusTorvalds2014 2014-12-09 12:37:10 -0800 11) cout << "Loops are fun!" << endl;
3922a6d8 (LinusTorvalds2014 2014-12-09 12:37:10 -0800 12) while(1);
ce59bbfd (Henry Garcia 2014-12-08 18:22:35 -0800 13) string reply = "Well, " + input + ", we hope you are having fun with our git-game!";
ce59bbfd (Henry Garcia 2014-12-08 18:22:35 -0800 14) cout << reply << endl;
ce59bbfd (Henry Garcia 2014-12-08 18:22:35 -0800 15) }
Now, the problem is very clearly the infinite loop, and we know from the blame that Linus did that. The README tells us to switch to the branch named LinusTorvalds2014.
~$ git checkout LinusTorvalds2014
Switched to a new branch 'LinusTorvalds2014'
~$ cat README.md
git-game
========
Looks like you found the branch of the evil Mastermind.
Things may start to get a little more challenging...
The next clue you are looking for --
is in a file you choose to ignore!
This clue took some time. I kept fluttering here and there, checking out the LICENSE file, as people tend to ignore the LICENSE mostly. Have you ever read an open-source license? I did. It’s quite weird. Anyways, it was only after i opened thunar (..my file manager) that i saw the .gitignore file. Any file starting with a “.” is automatically considered hidden, and hence doesn’t show up in ls. We need to use:
~$ ls -a
. .. .git .gitignore LICENSE README.md
Which shows the hidden folders and files as well. And the .gitignore was what i was looking for.
~$ cat .gitignore
# welcome to the ignore file!!
# This file is hidden by default,
# but did you know you have some branches that aren't shown to you,
# when you check the list of branches?
#
# For your next clue...
# Which abstract data type tends to implement sets and maps??
# The answer is the same answer to this riddle:
#
# I am both mother and father.
# I am seldom still
# yet I never wander.
# I never birth nor nurse.
#
# What am I?
#
# Afterwards... well, you
# know, checkout to the answer.
*.rem
a.out
I’m not sure how i got this answer. No idea. But the “i am seldom still, yet i never wander” helped me out a bit. The F.R.I.E.N.D.S. episode where Joey’s selling Christmas trees and he tells Phoebe that the tree is fulfilling its Christmas destiny, and then Chandler chimes in that Christmas is the only time that the trees get to roam around New York. This is where the idea came into my head and well, the branch was called “tree”.
~$ git checkout tree
Switched to a new branch 'tree'
~$ ls
LICENSE nextclue_input.cpp outputclue.sh README.md
~$ cat README.md
git-game
========
Welcome to the "tree" branch.
Looks like good ol' Linus modified the "nextclue_input.cpp" file.
Normally, when ran with the shell script "outputclue.sh", the "nextclue_input.cpp" file would give us the next hint.
Maybe, you should try running the shell script with the "nextclue_input.cpp" file and see what happens...
You can run the script by running the command "./outputclue.sh FILE" .
I really got derailed from the flow of the game at this point. I have no idea how i solved this part. I just ran the shell script and saw the output:
~$ ./outputclue.sh nextclue_input.cpp
Linus has been here...
I love messing with these amateur programmers!!
If you want some real fun, then you should try resolving a conflict between this branch (tree) and code4life.
I introduced a little bug that you should fix in the conflict. >:)
After you merge these 2 files you should run the shell script again!!
Good Luck!!!
Then i checked out the .cpp file, which showed that there was an infinite while(1) loop running. I just opened it up in VIM, removed that part, and ran the shell code again:
~$ ./outputclue.sh nextclue_input.cpp
Well, congratulations!! You fixed my conflict!!
If you would like to continue, then you should checkout to the mouse branch!!
Before i could move to the next branch, i had to commit all changes made by me:
~$ git add .
~$ git commit -m "Updating Stuff."
[tree 9a2ba6a] Updating Stuff.
1 file changed, 1 insertion(+), 1 deletion(-)
Now switching to the next branch called “mouse”.
~$ git checkout mouse
Switched to a new branch 'mouse'
~$ ls
LICENSE README.md remember
~$ cat README.md
git-game
========
Looks like you resolved your conflict and found our branch, congrats!!
Hmm...it seems this branch has a file that was seen before in another branch.
Do you "remember" what it is?
I think this file has something to do with the next clue, but it seems to be very ugly looking.
Maybe if we compare the "diff"erences between this file and the file from before we'll know where to go next...
Now, i vividly remember the “remember” file i had gotten earlier (..’cause it filled my screen with junk), on a different branch. This README just wanted me to check the difference between that and the file in this branch. So we compare the file in the “mouse” and “bug” branches:
git diff mouse bug -- remember
Which gave me the difference along with a lot of random strings. The thing that jumped out clearly was:
-Sn The next clue is: YtrydjKsYqebDoI3h bTINUeV6 pTVY8jnK2re HRwwNy25Ps6 ...
+Sn In a branch named: Henry YtrydjKsYqebDoI3h bTINUeV6 pTVY8jnK2re HRwwNy25Ps6 ...
That’s all i wanted. I jumped to the branch “Henry”. Easy right? NOPES. Turns out that Henry is also a tag that has been saved, so the checkout command automatically jumps to that instance. To stop this from happening, we need to remove the tag. We can either create a new tag related to the Henry keyword or just delete it, and then proceed. I chose to create a new one, since deleting important tags is seldom good.
~$ git tag HenryPoop && git tag -d Henry
Deleted tag 'Henry' (was b8ad33a)
~$ git checkout Henry
Switched to a new branch 'Henry'
~$ cat README.md
git-game
========
Welcome!! It looks like you made it to my Branch!!!
Generally you want to refrain from making tags the same name as branches, unless you have a good reason.
The tag is more like the stable release.
While the branch is more like the in progress feature, which will be added soon.
You're almost done!! Excited?? Hope you are! You have one more thing to do!
Now its time to update the master branch, updating is really useful when you fork a repository and your forked repo starts to get behind on commits. The repository to update from is: https://github.com/drami025/git-game.git
Don't cheat!!
Now is the time to update from the remote given in the README:
git remote add updatefromhere git@github.com:drami025/git-game.git
git pull updatefromhere master
Which updates the whole directory and gets a new README.md that says:
Git Game Finish Line
==========
You completed our Git Game!
Well you:
- viewed previous commits using "git log"
- traversed to previous commits
- checked out to different branches
- ran "git blame" to see who made changes to a file
- ran the diff command to see differences between branches
- saw what .gitignore included and how it works
- resolved merged conflicts
- saw issues with naming tags and branches the same name
- updated a local repository from a remote repository
Thanks for playing!
It also had an email address i could report to after completion, which i did, and i got an awesome completion badge as well:

You have to try out this game. Even if it’s your first foray into the git version control system. It was an awesome learning experience. The developer has gone through quite a lot of trouble to design this game. It has to be completed once..
Yo!