• +91 9723535972
  • info@interviewmaterial.com

GIT Interview Questions and Answers

Related Subjects

GIT Interview Questions and Answers

Question - 81 : - What is the use of the git config command?

Answer - 81 : -

The git config command is used to set git configuration values on a global or local level. It alters the configuration options in your git installation. It is generally used to set your Git email, editor, and any aliases you want to use with the git command.

Question - 82 : - What is the functionality of git clean command?

Answer - 82 : -

The git clean command removes the untracked files from the working directory.

Question - 83 : - What is SubGit and why is it used?

Answer - 83 : -

SubGit is a tool that is used to migrate SVN to Git. It transforms the SVN repositories to Git and allows you to work on both systems concurrently. It auto-syncs the SVN with Git.

Question - 84 : -
If you recover a deleted branch, what work is restored?

Answer - 84 : -

The files that were stashed and saved in the stashed index can be recovered. The files that were untracked will be lost. Hence, it's always a good idea to stage and commit your work or stash them. 

Question - 85 : - Explain the different points when a merge can enter a conflicted stage.

Answer - 85 : -

There are two stages when a merge can enter a conflicted stage.

1. Starting the merge process

If there are changes in the working directory of the stage area in the current project, the merge will fail to start. In this case, conflicts happen due to pending changes that need to be stabilized using different Git commands.

2. During the merge process

The failure during the merge process indicates that there’s a conflict between the local branch and the branch being merged. In this case, Git resolves as much as possible, but some things have to be fixed manually in the conflicted files.

Question - 86 : - What has to be run to squash the last N commits into a single commit?

Answer - 86 : -

In Git, squashing commits means combining two or more commits into one.

Use the below command to write a new commit message from the beginning.

git reset -soft HEAD~N &&git commit

But, if you want to edit a new commit message and add the existing commit messages, then you must extract the messages and pass them to Git commit.

The below command will help you achieve this: 

git reset -soft HEAD~N &&git commit -edit -m“$(git log -format=%B -reverse .HEAD@{N})”

Question - 87 : - What is the command used to fix a broken commit?

Answer - 87 : -

To fix a broken commit in Git, you may use the “git commit --amend” command, which helps you combine the staged changes with the previous commits instead of creating an entirely new commit.

Question - 88 : - How do you recover a deleted branch that was not merged?

Answer - 88 : -

To recover a deleted branch, first, you can use the git reflog command. It will list the local recorded logs for all the references. Then, you can identify the history stamp and recover it using the git checkout command.

Question - 89 : - How can you discover if a branch has already been merged or not?

Answer - 89 : -

There are two commands to determine these two different things.

git branch --merged - Returns the list of branches that have been merged into the current branch.

git branch --no-merged - Returns the list of branches that have not been merged.

Question - 90 : - What is “git cherry-pick”?

Answer - 90 : -

The command git cherry-pick enables you to pick up commits from a branch within a repository and apply it to another branch. This command is useful to undo changes when any commit is accidentally made to the wrong branch. Then, you can switch to the correct branch and use this command to cherry-pick the commit.

NCERT Solutions


Share your email for latest updates


Our partners