Skip to content

Latest commit

 

History

History
91 lines (73 loc) · 2.37 KB

02-Practice-Test-Resetting-and-Reverting.md

File metadata and controls

91 lines (73 loc) · 2.37 KB

Practice Test - Resetting and Reverting

Solutions to practice test - Resetting and Reverting

  • Run the cd command to move into the story-blog directory.

    Solution
    $ cd story-blog
    
  • Run the git log command 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 revert command 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 reset command 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 reset command 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 reset command 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 commit command to commit the latest changes done in the file.

    Solution
    $ git commit -am 'Finish hair-and-tortoise story'
    
  • Run the git log command 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 reset command 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