Git Reverting and Undoing Commits Quiz Quiz

  1. Git Revert Command

    What does the `git revert` command primarily do?

    1. It permanently removes a commit from the history.
    2. It creates a new commit that undoes the changes made by a specified commit.
    3. It moves the HEAD pointer to a previous commit, discarding all subsequent commits.
    4. It modifies the contents of an existing commit.
    5. It merges two branches without creating a merge commit.
  2. Git Restore Command

    What is the primary use of the `git restore` command in Git?

    1. To restore a deleted branch from the remote repository.
    2. To undo changes to files on your local disk, potentially undeleting deleted files.
    3. To undo changes made by a specific commit and create a new commit.
    4. To completely reset the repository to a previous state, discarding all changes.
    5. To merge two branches while resolving any conflicts automatically.
  3. Git Reset --hard Consequences

    What are the consequences of using the command `git reset --hard`?

    1. It only removes the commit from the staging area.
    2. It moves the HEAD pointer and resets the staging area and working directory to the specified commit, potentially losing uncommitted changes.
    3. It creates a new commit that reverts the changes from the specified commit.
    4. It merges the specified commit into the current branch.
    5. It stashes all local changes before resetting the head.
  4. Reverting a File to Previous Commit

    Which command is used to revert a specific file to a previously committed version without affecting the HEAD reference?

    1. git reset HEAD u003Cfileu003E
    2. git revert HEAD u003Cfileu003E
    3. git checkout HEAD u003Cfileu003E
    4. git branch u003Cfileu003E
    5. git stash push u003Cfileu003E
  5. Git Revert Advantages

    What is a key advantage of using `git revert` over `git reset`?

    1. It's faster and more efficient.
    2. It doesn't alter the commit history.
    3. It's safer as it doesn't remove or orphan commits.
    4. It automatically resolves conflicts.
    5. It can be used on remote branches without causing issues.
  6. Removing a File from a Commit

    What is the correct sequence of Git commands to remove a specific file from the last commit?

    1. git rm --cached u003Cfileu003E; git commit --amend
    2. git checkout HEAD^ -- u003Cfileu003E; git commit --amend
    3. git reset --soft HEAD~1; git rm --cached u003Cfileu003E; git commit --amend
    4. git revert u003Ccommit_hashu003E --no-commit -- u003Cfileu003E; git commit
    5. git stash; git checkout HEAD^ -- u003Cfileu003E; git stash pop
  7. Undoing a Git Commit Using a Terminal

    What command do you use in the terminal to undo a git commit after finding the specific commit ID?

    1. git remove u003Ccommit IDu003E
    2. git undo u003Ccommit IDu003E
    3. git revert u003Ccommit IDu003E
    4. git rollback u003Ccommit IDu003E
    5. git checkout u003Ccommit IDu003E
  8. What should you do after `git revert` in order to make the revert effective?

    After running the `git revert u003Ccommit_hashu003E --no-commit -- u003Cfile_pathu003E` command, what steps do you need to do to make the changes to remote repository?

    1. git add and git commit
    2. git push --force
    3. git stash
    4. git pull --rebase
    5. git ignore
  9. Which is the most suitable when you just made a mistake to your previous commit?

    Which git command is most suitable when you immediately catch a mistake after your last commit, like a typo in your commit message?

    1. git revert
    2. git rebase
    3. git reset
    4. git amend
    5. git commit new
  10. Git Reset Scenarios

    In what scenario is it best to use git reset?

    1. To undo changes on a remote branch.
    2. To move back in time to a particular commit in a branch's commit history, but avoid if others are working off those commits.
    3. To modify a commit message on a shared branch.
    4. To quickly stage all unstaged files.
    5. To resolve merge conflicts.