Exercises
Exercise 1 - Recovering Older Versions of a File
Audrey has made changes to the Python script that she has been working on for weeks, and the modifications she made this morning “broke” the script and it no longer runs. She has spent ~ 1hr trying to fix it, with no luck…
Luckily, she has been keeping track of her project’s versions using Git! Which commands below will let her recover the last committed version of her Python script called data_cruncher.py?
git checkout HEAD
git checkout HEAD data_cruncher.py
git checkout HEAD~1 data_cruncher.py
git checkout <unique ID of last commit> data_cruncher.py
Both 2 and 4
Exercise 2 - Reverting a Commit
Audrey is collaborating with colleagues on her Python script. She realizes her last commit to the project’s repository contained an error, and wants to undo it. Audrey wants to undo correctly so everyone in the project’s repository gets the correct change. The command git revert [erroneous commit ID] will create a new commit that reverses the erroneous commit.
Git revert is an operation that takes a specified commit and creates a new commit which inverses the specified commit.
Below are the right steps and explanations for Audrey to use git revert, what is the missing command?
________ Look at the git history of the project to find the commit ID
Copy the ID (the first few characters of the ID, e.g. 0b1d055).
git revert [commit ID]
Type in the new commit message.
Save and close
Exercise 3 - Understanding Workflow and History
What is the output of the last command in
Outputs:
Last updated