Git MCQs with answers Page - 4

Here, you will find a collection of MCQ questions on Git. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 828.03K Points
Coach

Q. What does git reset --hard do?

  • (A) Deletes commits only
  • (B) Resets HEAD but keeps changes
  • (C) Deletes commits and working directory changes
  • (D) Moves commits to staging area

A

Admin • 828.03K Points
Coach

Q. Which command restores a file from the last commit?

  • (A) git restore <file>
  • (B) git checkout <file>
  • (C) git reset <file>
  • (D) Both A and B

A

Admin • 828.03K Points
Coach

Q. What is the purpose of git cherry-pick?

  • (A) Pick a branch
  • (B) Apply a specific commit from another branch
  • (C) Delete a commit
  • (D) Merge all branches

A

Admin • 828.03K Points
Coach

Q. Which command is used to rename a branch?

  • (A) git branch -r
  • (B) git branch -m
  • (C) git rename
  • (D) git move

A

Admin • 828.03K Points
Coach

Q. What does git rebase do?

  • (A) Creates a new branch
  • (B) Replays commits on another base commit
  • (C) Deletes commit history
  • (D) Pushes changes

A

Admin • 828.03K Points
Coach

Q. Which Git command aborts an ongoing merge?

  • (A) git stop
  • (B) git merge --abort
  • (C) git cancel
  • (D) git reset merge

A

Admin • 828.03K Points
Coach

Q. Which command is used to see references of all branches and tags?

  • (A) git log
  • (B) git show-ref
  • (C) git ref
  • (D) git branch -a

A

Admin • 828.03K Points
Coach

Q. What does git blame show?

  • (A) Errors in code
  • (B) Who last modified each line
  • (C) Merge conflicts
  • (D) Deleted files

A

Admin • 828.03K Points
Coach

Q. Which command cleans untracked files?

  • (A) git reset
  • (B) git clean
  • (C) git remove
  • (D) git delete

A

Admin • 828.03K Points
Coach

Q. Which flag shows a compact commit history?

  • (A) git log --all
  • (B) git log --oneline
  • (C) git log --graph
  • (D) git log --short

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ