Top 20 GIT Interview Questions and Answers

As a DevOps Engineer, you must have good knowledge of version control system. Git is most widely used version control system. Here we consolidated top 20 GIT  interview questions and answers.

Que:1- What is GIT?

Ans: GIT is a distributed version control system and source code management system (SCM). You can handle small and large projects with speed and efficiency with Git.

Read Also : An Overview of Git – Core Concepts of Distributed Version Control System

Que:2- What is a repository in GIT?

Ans: A repository in GIT, contains a directory named .git, where it keeps all its metadata for the repository. The content of the .git directory are private.

Que:3- What are the differences between GIT and SVN?

Ans: The main differences between GIT and SVN are as follows,

                                 GIT                                          SVN
Git is less recommended for handling extremely large files or frequently changing binary files SVN can maintain multiple projects stored in same repository
GIT do not support ‘commits’ across multiple branches or tags SVN allows the creation of directories at any location in the repository.
Git is unchangeable. SVN allows developers to treat a tag as a branch and to create multiple revisions under a tag root.

 

Que:4- Reason behind GIT better than Subversion?

Ans:  GIT is an open source distributed version control system. It allows you to run ‘versions’ of a project, which show the changes that already were made to the code overtime.  It also allows you keep the previous track if necessary and undo those changes. Various developers can checkout and upload changes in their code and each change can be attributed to a specific developer.

Que:5- What is Staging Area in GIT?

Ans: Staging Area or Indexing is the area where git starts tracking and saving changes that happen in files. These changes reflect in the .git directory (Hidden Directory in Unix like OS).  

Que:6- What is the function of GIT PUSH in GIT?

Ans: GIT PUSH updates remote repository along with associated objects. 

Que:7- What is the purpose of branching in GIT?

Ans: Branching in GIT is that you can create your own branch and jump between those branches. It allows you to go to your previous work keeping your recent work intact.

Que:8- How to bring new features in the main branch?

Ans: To bring a new feature in the main branch,  git merge or git pull command can be used.

Que:9- What is a conflict in git?

Ans: A conflict arises when the commit that will be merged but has some change in one place and the current commit also has a change at the same place. Git will not be able to predict what changes should take precedence.

Que:10- What is the function of git clone?

Ans: The git clone command creates a copy locally of an existing Git repository. To copy of a central repository, cloning is the most common way used by programmers.

Que:11- How to delete a branch in GIT?

Ans: Once development branch is merged into the main branch, then development branch is not required at all. To delete a branch use the following command,

$ git branch –d [head]

Read Also : Git Tutorial – Practical Git Commands (Part-1)

Que:12- How can be resolved conflict in git?

Ans: Conflicts in git can be resolved by editing the files to fix the conflicting changes and then add the resolved files by running command git add after that to commit the repaired merge, run git commit. Git does know that you are in mid of a merger, so it sets the parents of the commit correctly.

Que:13- What is the function of ‘git checkout’ in git?

Ans: This “git checkout” command is used to update directories or specific files in working tree with those from another branch without merging it in the whole branch.

Que:14- What is the function of ‘git rm’?

Ans: To remove the file from the staging area and also off your disk ‘git rm’ is used.

Que:15- What is the function of ‘git stash apply’?

Ans: When you want to continue working where you have left your work, ‘git stash apply’ command is used to bring back the saved changes onto the working directory.

Que:16- What is the use of ‘git log’?

Ans: To get information about a specific commit in your project history- by author, date, content or history git log command is used.

Que:17- What is ‘git add’ is used for?

Ans: This ‘git add’ command adds file changes in your existing directory to your index.

Que:18- What is the function of ‘git reset’?

Ans: The “Git Reset” command is used to reset your index as well as the working directory to the state of your last commit.

Que:19- What is ‘bare repository’ in GIT?

Ans: To manage co-ordination with the distributed development team, especially when you are working on a project from multiple computers, “Bare Repository” is used. 

Que:20- What is the difference between ‘git remote’ and ‘git clone’?

Ans: The ‘git remote add’ command just creates an entry in your git config that specifies a name for a particular URL. While, ‘git clone’ creates a new git repository by copying and existing one located at the URL.

In this guide, you have gone through top 20 GIT interview questions and answers for devOps Engineers. Please comment below for queries or suggestions.

Read Also : Top 25 AWS Interview Questions and Answers

Read Also : Top 20 DevOps Interview Questions with Answers

 

Share on:

Ravindra Kumar

Hi, This is Ravindra. I am founder of TheCodeCloud. I am AWS Certified Solutions Architect Associate & Certified in Oracle Cloud as well. I am DevOps and Data Science Enthusiast.

Recommended Reading..

Leave a Comment