Git Interview Question-Answer

Q.1 What is the command to view all the commits made by a specific person (Jim)?

       A. git log – who=”Jim”

       B. git log -–author=”Jim”

       C. git log – “Jim”

       D. git log

Ans : git log -–author=”Jim”


Q.2 What is the significance of using –index in the git stash pop – – index command?

       A. To commit the files

       B. To checkout the files

       C. To index the files staged

       D. To pull the staged changes

Ans : To pull the staged changes


Q.3 What is the Git command to view the last three commits in a line?

       A. git last 3 commits

       B. git log -–oneline -3

       C. git show log -3

       D. git log

Ans : git log -–oneline -3


Q.4 What does the command git reset –hard HEAD ~3 do?

       A. Merges the last 3 commits to the master

       B. Discards the last 3 commits

       C. Does nothing

       D. Resets the head to 3 commits before the current commit

Ans : Discards the last 3 commits


Q.5 I want to take all the changes I made in the staging to my working directory. What command should I use to perform this operation?

       A. git revert

       B. git reset HEAD

       C. git reset TAIL

       D. git change

Ans : git reset HEAD


Q.6 What is the command to amend an incorrect commit message?

       A. Git does not have an option to amend messages

       B. Git commit –amend -m “correct message”

       C. Git correct message

       D. Git amend -m “Correct message”

Ans : Git commit –amend -m “correct message”


Q.7 Which command helps you track the revisions of your revisions in Git?

       A. Git reflog

       B. Git logref

       C. Git track

       D. Git revision trak

Ans : Git reflog


Q.8 git bisect is used to identify a commit that has introduced a bug.

       A. True

       B. False

Ans : True


Q.9 git reflog –verbose will print extra information on the screen.

       A. True

       B. False

Ans : True


Q.10 I have made a commit and discarded it. I can still retrieve that commit using git reflog.

       A. True

       B. False

Ans : True


Q.11 git reflog tracks the commits that are made and the commits that are discarded.

       A. True

       B. False

Ans : True


Q.12 What is the command to pick a commit from a specific branch and move it to another branch?

       A. Git move commit

       B. Git cherry-pick

       C. Git move branch

       D. None of the options

Ans : Git cherry-pick


Q.13 What is the Git command to move branch pointer to different commit without checkout?

       A. Git cherrypick

       B. Git update-ref

       C. Git reset head

Ans : Git update-ref


Leave a Comment