Menu Close

GIT Interview Questions

What is Git?

  • Git is a Distributed Version Control tool. It is compatible with distributed non-linear workflows as it offers data assurance for building good quality software.
  • Git is free and open-source.
  • It can be used for almost any kind of project, be it small or big in size. Git is known for its great speed and efficiency.
  • Git repositories are very easy to find and access.
  • Due to its certain features, Git is highly flexible, secure and compatible with your system.

What language is used in GIT?

  • C is the programming language that is used for creating Git which ensures that the overheads are reduced.

How much space do we get on GitHub?

  • We get a space of 1 GB but if it exceeds 1GB, we receive a polite email from GitHub Support requesting to reduce the size of the repository and scale it down. In addition, here we placed a limit of files exceeding 100 MB in size.

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.

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
  • GIT log : It is used to find the specific commit in the history.
  • GIT rm : It removes the files from the staging area and also of the disk.

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.

What is a bare repository?

  • Candidates can also come across this entry among top Git interview questions as a follow-up question.
  • A bare repository contains information regarding version control.
  • The bare repository does not contain any working files or the special.git sub-directory.
  • On the contrary, the bare repository contains all information of the .git subdirectory in the main directory directly.
  • The working directory contains the working tree, i.e., verified copies of project files and .git subdirectory with all Git related revision history for your repository.

Compare Git with SVN?

  • When it comes to handling the data with large size, Git is not widely preferred.
  • However, for users, it is possible to handle more than one project with the latter provided they remain in a same repository.
  • In multiple branches, the Git fails to support the commits while the SVN can do so easily.

What is SHAI name?

  • It is basically a string character which is responsible for the identification of the commit objects.
  • The fact is users are free to make the changes to the default commit objects and the same is used for knowing and locating the overall changes made with a track record of the same.

What is the definition of “Index” or “Staging Area” in GIT?

  • When you are making the commits, you can make innovation to it, format it and review it in the common area known as ‘Staging Area’ or ‘Index’.

What is git reflog?

  • Git holds a record of updates to the apex of branches employing a mechanism described reference logs, as known as reflogs.
  • Various Git commands receive a parameter for defining a reference (ref), a pointer to a commit.
  • Typical examples are; git checkout, git reset, git merge, etc.

What is git is-tree?

  • ‘git is-tree’ represents a tree object comprising the mode and the item name as well as the SHA-1 value of the tree or a blob.

What are the advantages of Git over SVN?

  • Since Git is an open source version control system it lets you run multiple versions of your project so that it shows the changes that are made to the code over time and if needed you can keep a track of the changes that you have made.
  • This means that large number of developers can make their own changes and upload those changes so that the changes can be attributed to the particular developers.

What is GIT stash?

  • The Git stash will take the working directory in the current state and index it to put on the stack at a later stage so that what you get is a clean working directory.
  • This means that if you are in the middle of some task and need to get a clean working directory and simultaneously you want to keep all your current edits then you can use the Git stash.

How do you create a Repository in Git?

  • To create a repository, you need to create a directory for the project if it does not already exist, and then simply execute the command “git init”.
  • By executing this command, a .git directory will be created inside the project directory i.e. now your project directory has turned into a Git repository.

What are Hooks in Git?

  • Git hooks are certain scripts that Git runs before or after an event like commit, push, update or receive. You will find the ‘hooks’ folder inside .git directory in your local repository.
  • You will find the build-in scripts here pre-commit, post-commit, pre-push, post push.
  • These scripts get executed locally before or after the occurrence of an event. You can also modify these scripts according to your needs and Git will execute the script when that particular event occurs.

What is SubGit?

  • SubGit is a tool that is used for SVN to Git Migration. It is developed by a company called TMate.
  • It converts the SVN repositories to Git and lets you do work on both the systems concurrently. It auto-syncs the SVN with Git.

What is the conflict in Git?

  • Candidates could generally land up with a question on the conflict in Git in the basic Git interview questions.
  • Git could handle the majority of merges on its own by leveraging its automatic features. Conflict is evident when two different branches make edits to the same line in a file.
  • Another scenario for conflict in Git occurs with the deletion of a file on one branch and modification of the same file in another branch.
  • Conflicts are general occurrences, especially when functioning in a team environment.

What is Gitlog and when you can use it?

  • It is basically a command that can be executed when it comes to finding the history of a project according to the date, changes made, the developer who handled it and usefulness of the same.

What is a gist in Git?

  • Gists are a great way to share the work of any developer.
  • They can share parts of files, full applications or single files.
  • Anyone can access gists at https://gist.github.com.
  • Each Gist is Git repository, which means, it can be forked, and cloned.