Top 20 Git Interview Questions and Answers 2019

In this post, we will see Git Interview Questions with Answers. Our main focus is to cover all possible questions which can be asked during the Interview.

Top 20 Git Interview Questions and Answers 2019

Questions & Answers:

Question 1: What is Git?

Git is a distributed revision control and source code management system with an emphasis on speed. The motive of Git is to manage a project or a set of files as they change over time. Git stores this information in a data structure called a Git repository. The repository is the core of Git.

To be very clear, a Git repository is the directory where all of your project files and the related metadata reside.

Question 2: Mention a few advantages of Git?

  • Git is an Open Source Distributed Version Control System.
  • Speed
  • Simplicity
  • Fully Distributed
  • Excellent support for parallel development, support for hundreds of parallel branches.
  • Integrity

Question 3: How to create a new Repository?

git init

Question 4: How to clone the Local Repository?

git clone /path/to/repository

Question 5: How to clone remote Repository?

git clone [email protected]:/path/to/repository

Question 6: How to add changes to Index?

git add <filename>

Question 7: How to add all changes to index?

git add*

Question 8: How delete or remove from Index?

git rm <filename>

Question 9: How to commit changes to the repository?

git commit –m “Commit message”

Question 10: How to push changes to the remote repository?

git push origin master

Question 11: How to connect a local repository to a remote Repository?

git remote add origin <server>

Question 12: How to update the local repository with remote changes?

git pull

Question 13: How to create a new branch?

git checkout –b <branch>

example: git checkout –b feature_1

Question 14: How to switch to the master branch?

git checkout master

Question 15: How to delete branch?

git branch –d <branch>

Question 16: How to push the branch to a remote repository?

git push origin <branch>

Question 17: How to merge changes from another branch?

git merge <branch>

Question 18: How to view changes between two branches?

git diff <source branch> <target branch>

example: git diff feature_1 feature_2

Question 19: How to create a tag?

git tag <tag> <commit ID>

example: git tag 2.0.0 1b2e1d75ff

Question 20: How to get commit IDs?

git log


q? encoding=UTF8&MarketPlace=IN&ASIN=B07HCXQZ4P&ServiceVersion=20070822&ID=AsinImage&WS=1&Format= SL250 &tag=7033b 21ir?t=7033b 21&l=am2&o=31&a=B07HCXQZ4P


q? encoding=UTF8&MarketPlace=IN&ASIN=B06Y16TG67&ServiceVersion=20070822&ID=AsinImage&WS=1&Format= SL250 &tag=7033b 21ir?t=7033b 21&l=am2&o=31&a=B06Y16TG67

q? encoding=UTF8&MarketPlace=IN&ASIN=B078YRTS86&ServiceVersion=20070822&ID=AsinImage&WS=1&Format= SL250 &tag=7033b 21ir?t=7033b 21&l=am2&o=31&a=B078YRTS86

q? encoding=UTF8&MarketPlace=IN&ASIN=1788471067&ServiceVersion=20070822&ID=AsinImage&WS=1&Format= SL250 &tag=7033b 21ir?t=7033b 21&l=am2&o=31&a=1788471067

ir?t=7033b 21&l=am2&o=31&a=1784390895

q? encoding=UTF8&MarketPlace=IN&ASIN=B01MD0T33X&ServiceVersion=20070822&ID=AsinImage&WS=1&Format= SL250 &tag=7033b 21ir?t=7033b 21&l=am2&o=31&a=B01MD0T33X

q? encoding=UTF8&MarketPlace=IN&ASIN=B07CD25M3F&ServiceVersion=20070822&ID=AsinImage&WS=1&Format= SL250 &tag=7033b 21ir?t=7033b 21&l=am2&o=31&a=B07CD25M3F

q? encoding=UTF8&MarketPlace=IN&ASIN=1788479351&ServiceVersion=20070822&ID=AsinImage&WS=1&Format= SL250 &tag=7033b 21ir?t=7033b 21&l=am2&o=31&a=1788479351

q? encoding=UTF8&MarketPlace=IN&ASIN=1783553472&ServiceVersion=20070822&ID=AsinImage&WS=1&Format= SL250 &tag=7033b 21ir?t=7033b 21&l=am2&o=31&a=1783553472



q? encoding=UTF8&MarketPlace=IN&ASIN=B07M67W1PH&ServiceVersion=20070822&ID=AsinImage&WS=1&Format= SL250 &tag=7033b 21ir?t=7033b 21&l=am2&o=31&a=B07M67W1PH