• +91 9723535972
  • info@interviewmaterial.com

GIT Interview Questions and Answers

Related Subjects

GIT Interview Questions and Answers

Question - 61 : - What does ‘hooks’ comprise of in Git?

Answer - 61 : -

This directory consists of shell scripts that are activated if you run the corresponding Git commands.  For example, git will try to execute the post-commit script after you have run a commit. 

Question - 62 : - How will you know in Git if a branch has already been merged into master?

Answer - 62 : -

The answer is pretty direct.

To know if a branch has been merged into master or not you can use the below commands:

git branch --merged – It lists the branches that have been merged into the current branch.
git branch --no-merged – It lists the branches that have not been merged.

Question - 63 : - Explain the difference between reverting and resetting.

Answer - 63 : -

  • Git reset is a powerful command that is used to undo local changes to the state of a Git repository. Git reset operates on “The Three Trees of Git” which are, Commit History ( HEAD ), the Staging Index, and the Working Directory.
  • Revert command in Git creates a new commit that undoes the changes from the previous commit. This command adds a new history to the project. It does not modify the existing history.

Question - 64 : - What is git cherry-pick?

Answer - 64 : -

The command git cherry-pick is normally used to introduce particular commits from one branch within a repository onto a different branch. Another common use is to forward- or back-port commits from a maintenance branch to a development branch. This is in contrast with other ways such as merge and rebase which normally apply many commits onto another branch.

Consider:

git cherry-pick

Question - 65 : - What is Git bisect? How can you use it to determine the source of a (regression) bug?

Answer - 65 : -

  • Git bisect is used to find the commit that introduced a bug by using binary search. The command for Git bisect is
  • git bisect
  • Now since you have mentioned the command above explain to them what this command will do.
  • This command uses a binary search algorithm to find which commit in your project’s history introduced a bug. You use it by first telling it a “bad” commit that is known to contain the bug, and a “good” commit that is known to be before the bug was introduced. Then Git bisect picks a commit between those two endpoints and asks you whether the selected commit is “good” or “bad”. It continues narrowing down the range until it finds the exact commit that introduced the change.

Question - 66 : - Name a few Git commands with their function.

Answer - 66 : -

  • Git config - Configure the username and email address
  • Git add - Add one or more files to the staging area
  • Git diff - View the changes made to the file
  • Git init - Initialize an empty Git repository
  • Git commit - Commit changes to head but not to the remote repository

Question - 67 : - What is the correct syntax to add a message to a commit?

Answer - 67 : -

 git commit -m "x files created"

Question - 68 : - Which command is used to create an empty Git repository?

Answer - 68 : -

git init - This command helps to create an empty repository while working on a project. 

Question - 69 : - What does git pull origin master do?

Answer - 69 : -

The git pull origin master fetches all the changes from the master branch onto the origin and integrates them into the local branch.

git pull = git fetch + git merge origin/ master

Question - 70 : - What does the git push command do?

Answer - 70 : -

The Git push command is used to push the content in a local repository to a remote repository. After a local repository has been modified, a push is executed to share the modifications with remote team members.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners