-
Notifications
You must be signed in to change notification settings - Fork 351
Exercise Scavenger Hunt
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, 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
andgit 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 themaster
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.
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 bahhhhh
into goat.c
? Who wrote that line? Hint: look at the mystery commits!
Make sure you're on master
(git checkout master
). Which commit removed the file foo.c
?
Click here for solutions.
Go back to the main page.