GIT Interview Questions

GIT Interview Questions

Define GIT?

Git is a Distributed Version Control system (DVCS). It can track changes to a file and allows you to revert back to any particular change.

Define ‘bare repository’ in Git?

A “bare” repository in Git it doesn’t contain the special .git sub-directory, just contains the version control information and no working files (no tree). Instead, it contains all the contents of the git sub-directory directly in the main directory itself, where as working directory consist of:  

  • A working tree, or checked out copies of your project files.
  • A .git subdirectory with all the Git related revision history of your repo.

What are the different ways you can refer to a commit?

In Git each commit is given a unique hash. These hashes can be used to identify the corresponding commits in various scenarios (such as while trying to checkout a particular state of the code using the git checkout {hash} command).

Additionally, Git also maintains a number of aliases to certain commits, known as refs. Also, every tag that you create in the repository effectively becomes a ref (and that is exactly why you can use tags instead of commit hashes in various git commands). Git also maintains a number of special aliases that change based on the state of the repository, such as HEAD, FETCH_HEAD, MERGE_HEAD, etc.

Git also allows commits to be referred as relative to one another. For example, HEAD~1 refers to the commit parent to HEAD, HEAD~2 refers to the grandparent of HEAD, and so on. In case of merge commits, where the commit has two parents, ^ can be used to select one of the two parents, e.g. HEAD^2 can be used to follow the second parent.

And finally, refspecs. These are used to map local and remote branches together. However, these can be used to refer to commits that reside on remote branches allowing one to control and manipulate them from a local Git environment.

What is a conflict in git and how can it be resolved?

A conflict arises when more than one commit that has to be merged has some change in the same place or same line of code. Git will not be able to predict which change should take precedence. This is a git conflict.

To resolve the conflict in git, edit the files to fix the conflicting changes and then add the resolved files by running git add. After that, to commit the repaired merge, run git commit. Git remembers that you are in the middle of a merge, so it sets the parents of the commit correctly.

What does commit object contains?

Commit object contains the following components, you should mention all the three points present below:

A set of files, representing the state of a project at a given point of time

Reference to parent commit objects

An SHAI name, a 40 character string that uniquely identifies the commit object.

What is SubGit?

SubGit is a tool for SVN to Git migration. It creates a writable Git mirror of a local or remote Subversion repository and uses both Subversion and Git as long as you like.

What is the HEAD in GIT ?

AHEAD is a reference to the present looked at conferring.

It is a representative reference to the branch that we have looked at.

At any given time, one head is chosen as the ‘present head’ this head is otherwise called HEAD (dependably in capitalized).

What are Git Design objectives?

Distributed workflow (decentralised)

Easy merging (merge deemed more frequent than commit)

Integrity (protection against accidental/malicious corruptions)

Speed & scalability

What is Version Control with Git?

Version control is better than mailing files back and forth because:

  • It’s is not impossible to coincidentally overwrite or overlook someone’s changes: whenever there’s a conflict between one person’s work and another’s, the version control system automatically notifies users.
  • If people are having some questions to ask, they will maintain the records what changes they have made.
  • Nothing that is committed to version control is ever lost. it’s always possible to go back in time to know exactly who wrote what on a particular day, or what version of a program was used to generate a particular set of results. This means it can be used like the undo feature in an editor, and since all previous versions of files are saved.

Git is one of many version control systems. It is more complex than some alternatives, but it is widely used, both because it’s easy to set up and because of a hosting site called GitHub, which we will get to later.

What are the main benefits of GIT ?

Distributed System: GIT is a Distributed Version Control System (DVCS). So you can keep your private work in adaptation control yet totally escaped others. You can work disconnected too.

⦁ Flexible Workflow:GIT enables you to make your own work process. You can utilize the procedure that is appropriate for your venture. You can go for brought together or ace slave or some other work process.

⦁ Fast: GIT is quick when contrasted with other form control frameworks.

⦁ Data Integrity: Since GIT utilizes SHA1, information isn’t less demanding to degenerate.

⦁ Free: It is free for individual utilize. Such huge numbers of beginners utilize it for their underlying activities. It likewise works exceptionally well with substantial size task.

⦁ Collaboration: GIT is anything but difficult to use for ventures in which joint effort is required. Numerous prevalent open source programming over the globe utilize GIT

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at, we will update the article in 24 hours.”

0 Responses on GIT Interview Questions"

    Leave a Message

    Your email address will not be published. Required fields are marked *


    Please leave a message and we'll get back to you soon.
    Three + 6