Top 20 GIT Interview Questions And Answers For 2020.

Vinay Agrawal
5 min readMay 25, 2020

--

Be it cloud computing, or DevOps, even Project Management, GIT is probably the best source code management tool of this era. According to Wikipedia, 42.9% of professional software developers reported that they use Git as their primary source-control system compared to 36.3% in 2013, and 32% in 2012 and 12.8% in 2011. You see, the number is increasing day by day. Isn’t it?

So, if you had queries about why you need to learn GIT, that’s clear with these statistics. Isn’t it?

With various extensions like git-annex, git-flow, git-machete, and many more, GIT definitely is stealing the show. Hence, if you are going to sit for your next interview as a developer, you need to learn a few stuff about GIT.

Did you learn about it already?

Great then!

The next step is to study a few QnAs to reach the success point well. And how would you know which questions to learn? Fret not! We have got your back here! We have prepared a few mostly asked questions and answers just for you! Have a look!

1. What is GIT?

GIT is a distributed version control system and source code management (SCM) system that empowers the users to handle small and large projects with speed and efficiency.

2. What is a repository in GIT?

A repository basically consists of a directory called .git, where all the metadata for the repository is stored. Only GIT has access to the content of .git directory.

3. What is the command you can use to write a commit message?

The command used to write a commit message is:

git commit –aYou can use “git add<file>” before git commit –an in the scenario of committing a new file for the first time.

4. What is the difference between GIT and SVN?

5. What are the advantages of using GIT?

The advantages of using GIT are:

  • Data redundancy and replication
  • High availability
  • Only one.git directory per repository
  • Superior disk utilization and network performance
  • Collaboration friendly
  • Any sort of projects can use GIT

6. What programming language is used in GIT?

The ‘C’ programming language reduces the overhead of runtimes associated with higher languages. And that’s what makes GIT faster.

7. What is the function of ‘GIT PUSH’ in GIT?

‘GIT PUSH’ updates remote refs along with associated objects.

8. Why GIT better than Subversion?

As an open-source version control system, GIT allows you to run ‘versions’ of a project that shows the changes made to the code over time. Along with that, it allows you to backtrack those changes and them if required. Multiple developers can check and upload changes and each change then be attributed to a specific developer.

9. What is the “Staging Area” or “Index” in GIT?

Before the commits are completed, it can be formatted and reviewed in an intermediate area called ‘Staging Area’ or ‘Index’.

10. What is GIT stash?

GIT stash takes the current state of the working directory and index and puts in on the stack for the future use and gives you back a clean working directory. If you are in the middle of something and need to jump over to the other job, at the same time you won’t have to lose your current edits with the help of GIT stash.

11. What is the GIT stash drop?

If you are done working with the stashed item and want to remove it from the list, you can run the git ‘stash drop’ command. It removes the last added stash item by default, and can also remove a specific item if you include it as an argument.

12. How will you know in GIT if a branch has been already merged into master?

Git branch — merged command shows you the branches that have been merged into the current branch through a list.

Git branch — -no merged command lists up the branches that have not been merged

13. What is the function of the git clone?

The git clone command creates a copy of an existing Git repository. Cloning is the most common way used by programmers to get a copy of the central repository.

14. What is the function of ‘git config’?

The ‘git config’ command helps in setting up the configuration options for your Git installation. The behavior of a repository, user info, preferences etc. can be defined through this command.

15. What does a commit object contain?

Commit object contains the following stuff:

  • A set of files that represents the state of a project at a given point of time
  • Reference to parent commit objects
  • An SHAI name that is basically a 40 character string that uniquely identifies the commit object.

16. How can you create a repository in Git?

To create a Git repository, you need to create a directory for the project if it does not exist. After than run the command “git init” to create .git directory in the project directory. You need to take care of the fact that the directory is not empty.

17. What is ‘head’ in git and how many heads can be created in a repository?

A ‘head’ is a reference to a commit object. Head can exist in any number of heads.

In every repository, a default head referred to as “Master”.

18. What is the purpose of branching in GIT?

Through branching, you can create your own branch and jump between those branches in GIT. It allows you to go to your previous work while keeping your recent work intact.

19. What is the common branching pattern in GIT?

The common way of creating a branch in GIT is to maintain one as “Main“

branch and create another branch to implement new features. This pattern is particularly useful when there are multiple developers working on a single project.

20. How can you bring a new feature to the main branch?

To introduce a new feature in the main branch, you can use the command “git merge” or “git pull command”.

Conclusion:

We hope now you are feeling a little more confident about your GIT basics. Although, if you are still having trouble, you can always reach out to us. Our Cloud training sessions and DevOps classes are full of GIT knowledge. Let’s see if we can shape your skills perfectly!

--

--

No responses yet