Git Revert Command
What does the `git revert` command primarily do?
- It permanently removes a commit from the history.
- It creates a new commit that undoes the changes made by a specified commit.
- It moves the HEAD pointer to a previous commit, discarding all subsequent commits.
- It modifies the contents of an existing commit.
- It merges two branches without creating a merge commit.
Git Restore Command
What is the primary use of the `git restore` command in Git?
- To restore a deleted branch from the remote repository.
- To undo changes to files on your local disk, potentially undeleting deleted files.
- To undo changes made by a specific commit and create a new commit.
- To completely reset the repository to a previous state, discarding all changes.
- To merge two branches while resolving any conflicts automatically.
Git Reset --hard Consequences
What are the consequences of using the command `git reset --hard`?
- It only removes the commit from the staging area.
- It moves the HEAD pointer and resets the staging area and working directory to the specified commit, potentially losing uncommitted changes.
- It creates a new commit that reverts the changes from the specified commit.
- It merges the specified commit into the current branch.
- It stashes all local changes before resetting the head.
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?
- git reset HEAD u003Cfileu003E
- git revert HEAD u003Cfileu003E
- git checkout HEAD u003Cfileu003E
- git branch u003Cfileu003E
- git stash push u003Cfileu003E
Git Revert Advantages
What is a key advantage of using `git revert` over `git reset`?
- It's faster and more efficient.
- It doesn't alter the commit history.
- It's safer as it doesn't remove or orphan commits.
- It automatically resolves conflicts.
- It can be used on remote branches without causing issues.
Removing a File from a Commit
What is the correct sequence of Git commands to remove a specific file from the last commit?
- git rm --cached u003Cfileu003E; git commit --amend
- git checkout HEAD^ -- u003Cfileu003E; git commit --amend
- git reset --soft HEAD~1; git rm --cached u003Cfileu003E; git commit --amend
- git revert u003Ccommit_hashu003E --no-commit -- u003Cfileu003E; git commit
- git stash; git checkout HEAD^ -- u003Cfileu003E; git stash pop
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?
- git remove u003Ccommit IDu003E
- git undo u003Ccommit IDu003E
- git revert u003Ccommit IDu003E
- git rollback u003Ccommit IDu003E
- git checkout u003Ccommit IDu003E
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?
- git add and git commit
- git push --force
- git stash
- git pull --rebase
- git ignore
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?
- git revert
- git rebase
- git reset
- git amend
- git commit new
Git Reset Scenarios
In what scenario is it best to use git reset?
- To undo changes on a remote branch.
- To move back in time to a particular commit in a branch's commit history, but avoid if others are working off those commits.
- To modify a commit message on a shared branch.
- To quickly stage all unstaged files.
- To resolve merge conflicts.