Top 30 Git Interview Questions and Answers [Updated 2020]

Git is the most popular source code management system—used by over 40 million people. Whether you're a programmer or a non-technical person, Git will help you with its collaboration features like bug tracking, task management, and wikis. 

Git plays a significant role in an organization to achieve DevOps. Looking at the popularity of Git, it's quite evident that there will be many job opportunities in the near future. If you’re in the market for one of these jobs, here are some of the Git interview questions that might help you in cracking the interview.

Big Data Hadoop and Spark Developer

Learn Big Data Basics from Top Experts - for FREEEnrol Now
Big Data Hadoop and Spark Developer

In this article, we’ll look at the various questions that could be asked in a Git interview, which are divided into three sections:

  • Basic Git interview questions
  • Intermediate Git interview questions
  • Advance Git interview questions

Let’s get started!

Basic Git Interview Questions

1. What is Git?

Git is a version control system for tracking changes in computer files and is used to help coordinate work among several people on a project while tracking progress over time. In other words, it’s a tool that facilitates source code management in software development.

Git favors both programmers and non-technical users by keeping track of their project files. It enables multiple users to work together and handles large projects efficiently.


2. What do you understand by the term ‘Version Control System’?

A version control system (VCS) is a system that records all changes made to a file or set of data, so a specific version may be called later if needed.

This helps ensure that all team members are working on the latest version of the file. 


3. What’s the difference between Git and GitHub?



Git is a version control system for tracking changes in computer files. The main point of Git is to manage projects, or a set of them when changes are made over time. It helps to track progress over time and coordinate work among several people on a project.

GitHub is a Git repository hosting service that provides a web-based graphical interface. GitHub helps every team member to work together on the project from anywhere, making collaboration easy.

FREE DevOps Certification Training

Master the fundamentals of DevOpsStart Learning
FREE DevOps Certification Training

4. What is a Git repository?

Git repository refers to a place where all the Git files are stored. These files can either be stored on the local repository or on the remote repository.


5. How can you initialize a repository in Git?

If you want to initialize an empty repository to a directory in Git, you need to enter the git init command. After this command, a hidden .git folder will appear in the folder. 


6. Name a few Git commands with their function.

  • 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

7. What are the advantages of using Git?

  • Faster release cycles
  • Easy team collaboration
  • Widespread acceptance 
  • Maintains the integrity of source code
  • Pull requests


8. What language is used in Git?

Git is a fast and reliable version control system, and the language that makes this possible is ‘C.’ 

Using C language reduces the overhead of run times, which are common in high-level languages.

9. What is a commit message, and how is the commit command executed?

The commit command is executed in a Git project to record the progress in the local repository. The commit command is executed only after the files to be committed have been added to the staging area using the git add command. 

The command that makes it possible to write a commit message is ‘git commit -m’


10. Name some of the popular Git hosting repositories.

  • GitHub
  • GitLab
  • BitBucket
  • Beanstalk
  • FogBugz
  • Surround SCM
  • Buddy

After having gone through the beginner’s level of Git interview questions, let us now level up to the following intermediate questions and answers.

Intermediate Git Interview Questions

11. Explain the git push command.

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.


12. Explain the git pull command.

Git pull is used to fetch and merge changes from the remote repository to the local repository. Git pull is a combination of two commands: git fetch; followed by git merge.


13. Difference between git fetch and git pull.

Git fetch

Git pull

  • Git fetches only downloads new data from a remote repository.
  • It does not integrate any of these new data into your working files.
  • Can be done any time to update the remote-tracking branches

Command - git fetch origin

                    git fetch –-all

  • Git pull updates the current HEAD branch with the latest changes from the remote server.
  • Downloads new data and integrate it with the current working files.
  • Tries to merge remote changes with your local ones.

Command - git pull origin master

14. What is a merge conflict in Git?

A merge conflict is an event that takes place when Git is unable to resolve differences in code between the two commits automatically. 

Git is able to automatically merge the changes only if the commits are on different lines or branches.


15. How do you resolve a merge conflict?

To resolve a merge conflict in Git, follow these steps:

  • The most simple way to resolve the conflicted file is to open it and make the required changes
  • After editing the file, we can use the git add a command to stage the new merged content
  • The final step is to create a new commit with the help of the git commit command
  • Git will create a new merge commit to finalize the merge

16. What is the process to revert a commit that has already been pushed and made public?

There are two processes through which you can revert a commit:

1. Remove or fix the bad file in a new commit and push it to the remote repository. Then commit it to the remote repository using:

git commit –m “commit message”

2. Create a new commit to undo all the changes that were made in the bad commit. Use the following command:

git revert <commit id>

17. How is a bare repository different from the standard way of initializing a Git repository?

Using a standard way

Using a bare way

  • You create a working directory with the git init command
  • A .git subfolder is created with all the git-related change history
  • Does not contain any working or checked out a copy of source files
  • Bare repositories store git revision history in the root folder of your repository instead of the .git subfolder

18. What is Git stash?

Let’s say you're a developer and you want to switch branches to work on something else. The issue is you don’t want to make commits in uncompleted work, so you just want to get back to this point later. The solution here is the Git stash. 

Git stash takes your modified tracked files and saves it on a stack of unfinished changes that you can reapply at any time. To go back to the work you can use the stash pop.

19. What does the git reset --mixed and git merge --abort commands do?

git reset --mixed is used to undo changes made in the working directory and staging area.

git merge --abort helps stop the merge process and return back to the state before the merging began.

20. How do you find a list of files that has been changed in a particular commit?

The command to get a list of files that has been changed in a particular commit is:

git diff-tree –r {commit hash}

  • -r flag allows the command to list individual files
  • commit hash lists all the files that were changed or added in the commit.

Now let’s increase the level of difficulty with advanced Git interview questions and answers.

Interested to learn more about Git? Check out the DevOps Engineer Master's Program and get certified today.

FREE GIT Training

Learn the basics of GITEnrol Now
FREE GIT Training

Advanced Git Interview Questions

21. Explain the different points when a merge can enter a conflicted stage.

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

22. What is the difference between fork, branch, and clone?




The fork is the process when a copy of the repository is made. It's usually experimentation in the project without affecting the original project. They’re used to advise changes or take inspiration from someone else’s project.

Git branches refer to individual projects within a git repository. If there are several branches in a repository, then each branch can have entirely different files and folders.

Git clone refers to creating a clone or a copy of an existing git repository in a new directory. Cloning automatically creates a connection that points back to the original repository, which makes it very easy to interact with the central repository.

23. What is the difference between git merge and git rebase?

To incorporate new commits into your feature branch, you use merge


  • Creates an extra merge commit every time you need to incorporate changes
  • Pollutes your feature branch history

As an alternative to merging, you can rebase the feature branch into master.


  • Incorporates all the new commits in the master branch
  • Rewrites the project history by creating brand new commits for each commit in the original branch

24. What is the command used to fix a broken commit?

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.

25. How is ‘git remote’ different from ‘git clone’?

git remote

git clone

git remote enables you to create, view, and delete connections to other repositories. It's used to refer to a remote repository or a central repository.

git clone enables you to create a clone or copy of the target repository. It's used to target a different already existing repository.

26.  What is git stash drop?

The Git stash drop command is used to remove a particular stash. If there’s a stash you're no longer using or you want to remove a specific item of stash from the list, you can use the stash commands.

Let’s say you want to delete an item named stash@{abc}; you can use the command git stash drop stash@{abc}.

27. If you recover a deleted branch, what work is restored?

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

28. What’s the difference between reverting and resetting?



The revert command in Git is used to create a new commit that undoes the changes made in the previous commit. When you use this command, a new history is added to the project; the existing history is not modified.

Git reset is a command that is used to undo the local changes that have been made to a Git repository. Git reset operates on the following: commit history, the staging index, and the working directory.

29. How can you discover if a branch has already been merged or not?

There are two commands to determine these two different things.

  1. git branch --merged - Gives the list of branches that have been merged into the current branch.
  2. git branch --no-merged - Gives the list of branches that have not been merged.

30. What is “git cherry-pick”?

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.

Become a DevOps Expert!

By now you should have an idea of the Git questions that could be asked and what possible answers should be given. 

Preparing for a career in DevOps? Simplilearn's DevOps Certification Training Course teaches you about the tools and techniques you need to bridge the gap between software developers and operations. You’ll become an expert in the principles of continuous development and deployment, automation of configuration management, inter-team collaboration, and IT service agility, using modern DevOps tools such as Git, Docker, Jenkins, Puppet, and Nagios. DevOps jobs are highly paid and in great demand, so start on your path today!

About the Author


Simplilearn is one of the world’s leading providers of online training for Digital Marketing, Cloud Computing, Project Management, Data Science, IT, Software Development, and many other emerging technologies.

View More
  • Disclaimer
  • PMP, PMI, PMBOK, CAPM, PgMP, PfMP, ACP, PBA, RMP, SP, and OPM3 are registered marks of the Project Management Institute, Inc.