Git interview questions and answers 👇

  1. GIT Interview Questions

GIT Interview Questions

What is git?

View answer

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.

What is git stash?

View answer

git stash temporarily shelves (or stashes) changes you've made to your working copy so you can work on something else, and then come back and re-apply them later on.

What does a commit object contain?

View answer

The commit object contains:

  • directory tree object hash
  • parent commit hash
  • author
  • committer
  • date
  • message

What is the purpose of branching?

View answer

Branching is used in version control and software management to maintain stability while isolated changes are made to code. Branching facilitates the development of bug fixes, the addition of new capabilities and the integration of new versions after they have been tested in isolation.

What is a conflict?

View answer

A conflict arises when two separate branches have made edits to the same line in a file, or when a file has been deleted in one branch but edited in the other. Conflicts will most likely happen when working in a team environment.

What is rebase?

View answer

Rebasing is the process of moving or combining a sequence of commits to a new base commit.

What is git status?

View answer

The git status command displays the state of the working directory and the staging area.

What is git checkout used for?

View answer

The git checkout command lets you navigate between the branches created by git branch. Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch.

What are hooks?

View answer

Git hooks are scripts that run automatically every time a particular event occurs in a Git repository. They let you customize Git's internal behavior and trigger customizable actions at key points in the development life cycle.

What is git fetch?

View answer

Git Fetch is the command that tells the local repository that there are changes available in the remote repository without bringing the changes into the local repository.

What is staging area?

View answer

Staging area is files that are going to be a part of the next commit, which lets git know what changes in the file are going to occur for the next commit.

What is an index?

View answer

Git Index may be defined as the staging area between the workspace and the repository. The major use of Git Index is to set up and combine all changes together before you commit them to your local repository.

What is reflog?

View answer

Reflog is a mechanism to record when the tip of branches are updated.

How do you resolve a conflict in git?

View answer

Here's what you can do:

  • Identify the files responsible for the conflicts
  • Implement the desired changes to the files
  • Add the files using the git add command
  • Commit the changes in the file with the help of the git commit command

What is git clone?

View answer

The git clone commands allows you to create a local copy of the remote GitHub repository. Once you clone a repo, you can make edits locally in your system rather than directly in the source files of the remote repo.