Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Exercise Scavenger Hunt
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:
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.
Make sure you've already done the Github forking exercise before doing this. Once you have the
bootcamp-git directory on your computer,
You may find these commands useful for this exercise (note that commits are identified by the hashes when you type
git lg, e.g.
git lg(setup the alias above)
git diff COMMIT1 COMMIT2see all the changes between commits COMMIT1 and COMMIT2
git show COMMITsee what changes are introduced by a specific commit
git checkout COMMITcheckout 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 mastercheckout the
git blame FILEwho 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.
What files existed as of commit
4b40046 (Adding aliases)? Hint: use the checkout command.
Make sure you are on
master before starting this question (run
git checkout master).
Which commit introduced the line
goat.c? Who wrote that line? Hint: look at the mystery commits!
Make sure you're on
git checkout master). Which commit removed the file
Click here for solutions.
Go back to the main page.