- Take me to Practice Test
Solutions to practice test - Resetting and Reverting
-
Run the
cdcommand to move into the story-blog directory.Solution
$ cd story-blog -
Run the
git logcommand with it's appropriate option to check the history of commits with changed files lists.Solution
$ git log --name-only # count the number of files changed in the last commit. -
Run the
git revertcommand to undo all the changes made in the previous commit. It will open the file in the editor, we don't need to change anything. Save the file with default commit message.Solution
$ git log $ git revert <last-commit-id> -
Run the
git resetcommand with it's appropriate option which can be used to retain changes that were made on target commit after the reset operation.Solution
$ git help reset $ git reset --soft -
Run the
git resetcommand with it's appropriate option which can be used to drop changes that were made on target commit after the reset operation.Solution
$ git help reset $ git reset --hard -
Run the
git resetcommand to revert the last commit but retain the unfinished changes. The last commit must not be part of the GIT history.Solution
$ git help reset $ git reset --soft HEAD~1 -
Run the
git commitcommand to commit the latest changes done in the file.Solution
$ git commit -am 'Finish hair-and-tortoise story' -
Run the
git logcommand to check the logs and count the number of commits made since she previously finished her story.Solution
$ git log $ git log --name-only # With file name -
Run the
git resetcommand with it's appropriate option to remove all commits and changes she made since the commit "Finish hair-and-tortoise story".Solution
$ git log $ git reset --hard HEAD~3