Here is a list of Git Interview Questions and Answers:
Q. What is Git ?
Git is an open source distributed version control system build by Linus Trovalds.
Q. What are the advantages of Version Controlling ?
Version controlling helps to keep track of changes added to a system and helps in collaboration among teams by bringing in accountability and ensuring that files don’t get overwritten or loss of additions.
Q. What is difference between git pull and git fetch ?
Git pull command pulls in changes or commits from a branch of central repo and automatically updates the target branch of your local repo by merging.
Git fetch on the other hand pulls in changes / commits from a branch of central repo and stores it in a new branch in local repository. Unlike git pull, it doesn’t automatically merge the changes in your target branch and it has to be done manually by git merge command.
Q Git is written in which language ?
Git is written in C language which makes it blazingly fast and efficient for various operations which would have taken a longer time in other higher level languages.
Q What is ‘staging area’ or ‘index’ in git and what is it’s advantage ?
Staging area or index in git is a transition phase where changes are kept before commit them. Advantage of keeping a staging area is to selectively commit changes. For example you have written two features A and B in your code, now feature A is complete and feature B is incomplete and you want to commit only feature A. Now you can simply put files of feature A to the staging area or index and then when you do git commit, it only commits feature A changes.