Skip to content

Exercise Scavenger Hunt

Robert Adams edited this page Sep 4, 2018 · 9 revisions

Git setup, and useful tidbits

First, let's setup your git identity:

git config --global user.name "YOUR NAME"
git config --global user.email "YOUR EMAIL ADDRESS. Use whatever email you want."

Now, to add color to the output of your git commands:

git config --global color.ui auto

Finally, to add a very useful alias to visualize your git history:

git config --global alias.lg "log --graph --branches --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"

This will add the useful alias git lg to visualize your git history:

lg

NOTE: If you're wondering what the git config --global is, all it does is edit your global git configuration file, located in ~/.gitconfig. You can edit this file directly instead of running the git config --global command.

Scavenger Hunt

Make sure you've already done the Github forking exercise before doing this. Once you have the bootcamp-git directory on your computer, cd bootcamp-git.

You may find these commands useful for this exercise (note that commits are identified by the hashes when you type git lg, e.g. 032fdc36)

  • git log and git lg (setup the alias above)
  • git diff COMMIT1 COMMIT2 see all the changes between commits COMMIT1 and COMMIT2
  • git show COMMIT see what changes are introduced by a specific commit
  • git checkout COMMIT checkout the state of your project at an earlier commit. This allows you to examine the state of your project at some point in your project's history
  • git checkout master checkout the master branch again
  • git blame FILE who wrote each line of the file, and what commit introduced these changes?

For these exercises, please record the commands that you ran to see the answer, and also record the answer.

Question 1

What files existed as of commit 4b40046 (Adding aliases)? Hint: use the checkout command.

Question 2

Make sure you are on master before starting this question (run git checkout master).

Which commit introduced the line bahhhhh into goat.c? Who wrote that line? Hint: look at the mystery commits!

Question 3

Make sure you're on master (git checkout master). Which commit removed the file foo.c?

Solutions

Click here for solutions.

Finish Bootcamp

Go back to the main page.

You can’t perform that action at this time.