Jennifer 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
Jennifer 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. Jennifer 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.
The command git revert
is
different from git checkout [commit ID]
because git checkout
returns the
files not yet committed within the local repository to a previous state, whereas git revert
reverses changes committed to the local and project repositories.
Below are the right steps and explanations for Jennifer 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
What is the output of the last command in
$ cd planets
$ echo "Venus is beautiful and full of love" venus.txt
$ git add venus.txt
$ echo "Venus is too hot to be suitable as a base" venus.txt
$ git commit -m "Comment on Venus as an unsuitable base"
$ git checkout HEAD venus.txt
$ cat venus.txt #this will print the contents of venus.txt to the screen
Venus is too hot to be suitable as a base
Venus is beautiful and full of love
Venus is beautiful and full of love
Venus is too hot to be suitable as a base
Error because you have changed venus.txt without committing the changes