Git Interview Questions

  • (4.0)
  • | 8528 Ratings

If you're looking for Git Interview Questions for Experienced or Freshers, you are at right place. There are a lot of opportunities from many reputed companies in the world. According to research, Git has a market share of about 68%. So, You still have the opportunity to move ahead in your career in Git Development. Mindmajix offers Advanced Git Interview Questions 2019 that helps you in cracking your interview & acquire dream career as Git Developer.

Are you interested in taking up for GIT Certification Training? Enroll for Free Demo on GIT Training!

Q1. What is GIT and What are it's advantages?

Ans. Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Q2. What is the relationship between GIT and SCM tools?

Ans. SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.

Q3. Can you explain about Branching and Merging in GIT?

Ans. The Git feature that really makes it stand apart from nearly every other SCM out there is its branching model. Git allows and encourages you to have multiple local branches that can be entirely independent of each other. The creation, merging, and deletion of those lines of development takes seconds.

Q4. How do you rate GIT in terms of speed?

Ans. Git is fast. Speed and performance have been a primary design goal of the Git from the start. With Git, nearly all operations are performed locally, giving it a huge speed advantage on centralized systems that constantly have to communicate with a server somewhere.

Git was built to work on the Linux kernel, meaning that it has had to effectively handle large repositories from day one. Git is written in C, reducing the overhead of runtimes associated with higher-level languages.

Q5. What is a pull in git?

Ans. git-pull - Fetch from and integrate with another repository or a local branch

SYNOPSIS: git pull [options] [ […?]]

In its default mode, git pull is shorthand for git fetches followed by git merge FETCH_HEAD. More precisely, git pull runs git fetch with the given parameters and calls git merge to merge the retrieved branch heads into the current branch. should be the name of a remote repository as passed to git-fetch

Q6. What does git commit a?

Ans. Basically git commit "records changes to the repository" while git push "updates remote refs along with associated objects". So the first one is used in connection with your local repository, while the latter one is used to interact with a remote repository.

Q7. Why do you use GIT?

Ans. Git is a version control system (VCS) for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development but it can be used to keep track of changes in any set of files.

Q8. What is the purpose of Git?

Ans. The purpose 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 repository.

Q9. What do you mean by git add?

Ans. git add . adds all modified and new (untracked) files in the current directory and all subdirectories to the staging area (a.k.a. the index), thus preparing them to be included in the next git commit. Any files matching the patterns in the .gitignore file will be ignored by git add.

Q10. What is the difference between Git and Github?

Ans. Git is a revision control system, a tool to manage your source code history.

GitHub is a hosting service for Git repositories.

GitHub is a website where you can upload a copy of your Git repository. It is a Git repository hosting service, which offers all of the distributed revision control and source code management (SCM) functionality of Git as well as adding its own features.

Q11. What does a git pull rebase do?

Ans. git pull --rebase is allows you to later squash your commits to a few (or one) commits. If you have merged in your (unpushed) history, it is not so easy to do a git rebase later one.

Q12. What does git pull origin master do?

Ans. git pull origin master pulls the master branch from the remote called origin into your current branch. It only affects your current branch, not your local master branch.

Q13. What is a stash in git?

Ans. Stashing takes the dirty state of your working directory, that is, your modified tracked files and staged changes and saves it on a stack of unfinished changes that you can reapply at any time.

Q14. What is git pull origin?

Ans. pull is a fetch and a merge. * `git pull origin master` fetches commits from the master branch of the origin remote (into the local origin/master branch), and then it merges origin/master into the branch you currently have checked out.

Q15. Give a definition of GIT and also state what repository in GIT?
Ans. A control system which is on a distributed version platform is described as GIT. It is also considered as a management system that is based on open source. GIT gives importance to managing large and small projects that too with efficiency and speed. 

GIT directory is present in a repository and with the help of this GIT keeps each and every metadata. The content that is present in this directory is private for GIT. 

Q16. Differentiate between SVN and GIT. 


  • When it comes to managing very large files and certain other files that are considered as binary files which are changing on a frequent basis, preference is given more to SVN as it is capable of managing several projects which are contained in the certain repository. 
  • The method of 'commits' is applied among several tags and branches, is not supported by GIT. With the help of subversion, you will be able to create folders in repository layout that too at any preferred location. 
  • GIT cannot be changed but SVN allows the creation of several revisions under one certain tag root and it also allows using a tag in the form of a branch. 

Q17. Mention the benefits of young GIT. 

Ans. These are the following benefits of using GIT. 

1. There is the chance of data replication and redundancy. 
2. You will get a high rate of availability. 
3. For each repository, there is a single.GIT directory. 
4. With the help of GIT, you will get a high level of network performance and also disk Utilization. 
5. Also, GIT is collaboration friendly. 
6. GIT can be used for all kinds of projects. 

Q18. Mention the factors which make GIT better when compared to subversion. Also, write the functionality of GIT push. 

Ans. Since GIT is a version control system that is open source in nature, this will give you permission to run those versions that highlight the changes which were applied to codes during overtime. With the help of this, you will also be able to keep backtrack so that you can go back and undo the changes if required. Checkout by multiple developers is possible. They can upload changes. After the upload process, each of these changes will be attributed to each specific developer.

The functionality of the command, GIT push is to update those refs that are remote and they are updated along with associated objects. 

Q19. What do you mean by GIT stash? Also, mention the purpose of index or staging area in GIT. 

Ans. The process which takes the present state of index and directory that is working and then for later purpose puts them on a stack to provide you with a fresh working directory is referred to as GIT stash. GIT stash can be utilized at the time of using a single project but you have to jump to some other project without losing edits on the previous one. 

Index or staging area is referred to that intermediate area where the commits are reviewed and formatted before completion. 

Q20. Mention the process that will help us to know whether a branch in GIT is already merged into a master or not. Also, state the function of GIT clone. 

Ans. The merged GIT branch will give a list of branches which have undergone merging process to the current branch. Also, the no merged GIT branch list will give the list of branches which have not undergone merging process. 

In order to create another copy of a GIT repository that already exists, the GIT clone command is used. 

Q21. Name contains for commit object. Give the functionality of the command GIT Config. 

Ans. The contains of commit object are described below-

1. It contains files which are used for representing the project’s state at a particular time. 
2. It also contains a name known as SHAI. This is a character string of length 40 characters which are used for identifying the commit objects uniquely. 

The command which is used for setting configuration options for GIT installation in the most convenient way is referred to as GIT Config. You can identify user information, repository and preferences with the help of this command. 

Q22. Write the method in which a repository is created on GIT. Also, give a description of 'head' in GIT and mention the number of heads that are created in a repository. 

Ans. First, in order to make a repository in GIT, you will need to make a directory in case there is no existing directory. You will need to run the command named, GIT.init which will create a .GIT directory in the directory of the project. 

Head is used to refer as commit object in GIT. A default directory known as Master is present in each and every repository. A particular repository will be able to contain any quantity of heads. 

Q23. Why is branching needed in GIT? Mention the common branching patterns in GIT. 

Ans. In GIT, with the help of branching facility, you will be able to create branches of your own and also you can jump among these branches. With the help of this facility, you will be able to jump to new work from the previous work and your previous work will remain intact. 

In GIT the most common pattern of making branching is by fixing one branch as the main one and then creating a new branch for the purpose of implementation of new features. If there are several developers who are working on the same project then this pattern is helpful. 

Q24. Mention the method of introducing new features in the main branch. What do you mean by conflict?

Ans. By using the command, GIT pull or GIT merge you will be able to add new features to the main branch. 

Sometime there might be a situation when at a particular place there are certain changes in the merger commit and also the in case of current commit there are changes at that same place. In this scenario, conflict arises and it is quite difficult for GIT to determine what change will take precedence. 

Q25. Mention the command which is used from deleting a branch in GIT. In GIT, how can you resolve a conflict?

Ans. The development branch is not needed once you have merged into the main branch. So it is wishful to delete this branch and to do to make use of the command called, GIT branch - d[head]. 

Conflicts are often seen in GIT. In order to resolve it, you will need to edit files so that the change which was conflicting can be fixed. After this, the files which are resolved should be added using the command, GIT add. For the purpose of committing repaired damages, you have to run the command, GIT commit. The parents belonging to commit are set properly. 

Q26. Mention the syntax which is used for rebasing in case of GIT. Mention another option of merging used in GIT. 

Ans. In GIT, the syntax which is used for rebasing is called, GIT rebase [new-commit]. 
Another way of merging in case of GIT is known as rebasing. 

Q27. What do you mean by version control in GIT? 

Ans. If you want to keep track of collections of files including the functionality that will help in reverting the file collection to a different version then you will need the help of version control. At a particular time, a picture of a file system is captured by a version. Also, the repository stored the complete history of the collection of files. 

Q28. Write a few the graphical GIT clients that are used in case of Linux. 

Ans. The graphical GIT clients are:-

1. GIT clone 
2. GIT-g
3. Smart GIT
5. Giggle 
6. qGIT 

Q29. Mention the functionality of GIT diff.

Ans. In order to showcase the changes that are present among commit, working tree you should make use of the command, GIT diff.

Q30. Mention the use of GIT status. 

Ans. With the help of GIT status, you will be able to see the difference among the index and also the directory which is in the working phase. You will be able to understand the GIT in a more comprehensive way with this GIT status. 

Q31. Differentiate between GIT diff and GIT status. 

Ans. With the help of GIT diff, you will be able to see the differences among all types of commit and also among the working index and directory.

Q32. Mention the functionality of GIT checkout. 

Ans. The command which is used for updating the directories and also to specify files present in the working tree from those belonging to another directory without being merged to the entire branch is known as GIT checkout. 

Q33. Mention the functionality of GIT.rm. 

Ans. In order to remove files from the disk and those which are present in the area of staging, you should make use of the command, GIT.rm. 

Q34 Mention the usage of stash apply command in GIT? 

Ans. To bring back those changes that were saved in the directory that is working you should make use of the command GIT stash apply. 

Q35. Mention the usage of GIT log function. 

Ans. GIT log command is used to find certain specific commits that are present in the project history through date, author or content. 

Q36. Why do we use GIT add? 

Ans. To add changes in the file of the directory that is existing to the index, we make use of the command, GIT add. 

Q37. What are GIT repository hosting services?

Ans. The GIT repository hosting services are-

1.  Pikacode 
2. GitHub 
3. Visual studio online 
4. GITenterprise 
5. Source

Q38. Mention the functionality of GIT reset command. 

Ans. If you want to reset the index and also the directory which is in working mode to the last commit state then make use of the GIT reset command. 

Q39. What do you mean by Is-tree in GIT? 

Ans. To represent tree objects which also include names of all items and also the mode and the tree or blobs' SHA-1 value, GIT is-tree is used. 

Q40. Mention the use of GIT Instaweb. 

Ans. In order to direct a web browsing portal automatically and also to run the webserver with the help of an interface on to a local repository, GIT Instaweb is used.

Q41. Mention the command which is used for writing a commit message in GIT. 

Ans. In order to write a commit message in GIT, the command used in GIT commit - a. This - a will allow the GIT to commit all the new content of tracked files which have been modified. And in case you need to commit new files for the very first time then make use of GIT add before you write GIT commit - a. 

Q42. Name the language which is used in case of GIT. 

Ans. With the help of C language, there is a reduction of overhead runtimes which are associated with languages that are present in the higher-order. Since GIT is fast so C language is the most preferred language. 

Q43. Mention the definition and use of subGIT.

Ans. One tool which is used for the purpose of stress-free, smooth SVN to GIT migration is known as submit. The various uses of subGIT are:-

1. This is better than GIT-SVN 
2. You will not need to change the already placed infrastructure. 
3. You will get a stress free genuine migration experience. 
4. You will be able to use all types of GIT and subversion features. 

Q44. Give the difference between GIT clone and GIT remote.

Ans. The command GIT remote will help in creating an opening for the GIT configuration which mentions a name for a specified URL. In order to create a new GIT repository, you will need to use the command, GIT clone that performs the task of copying an already existing one which is located in the URL. 

Q45. What are the top Git commands?


Command Usage Description
git config git config –global user.the name “[name]” This command sets the author name to be used with your commit.
git init git init [repository name] This command starts a new repository.
git clone git clone [url] This command is used for obtaining a repository from an existing URL.
git add git add [file] This command adds a file to the staging area
git commit git commit -m “[ Type in the commit message]” This command records/snapshots the file permanently in the version history
git status git status This command lists all the files that have to be committed.
git rm git rm [file] This command deletes the file from your working directory and stages the deletion.

Explore Git Sample Resumes! Download & Edit, Get Noticed by Top Employers!Download Now!

Subscribe For Free Demo

Free Demo for Corporate & Online Trainings.

Priyanka Vatsa
About The Author

Priyanka Vatsa is a Senior Content writer with more than five years’ worth of experience in writing for Mindmajix on various IT platforms such as Palo Alto Networks, Microsoft Dynamics 365, Siebel, CCNA, Git, and Nodejs. She was involved in projects on these technologies in the past, and now, she regularly produces content on them. Reach out to her via LinkedIn and Twitter. Protection Status