Git interview questions 2022

What is GIT?

GIT is a distributed version control system and source code management (SCM) system with an emphasis to handle small and large projects with speed and efficiency.

What is a repository in GIT?

A repository contains a directory named .git, where git keeps all of its metadata for the repository. The content of the .git directory are private to git.

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

The command that is used to write a commit message is “git commit –a”.  The –a on the command line instructs git to commit the new content of all tracked files that have been modified. You can use “git add<file>” before git commit –a if new files need to be committed for the first time.

What are the advantages of using GIT?

  • 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 GI

What is “Staging Area” or “Index” in GIT?

Before completing the commits, it can be formatted and reviewed in an intermediate area known as ‘Staging Area’ or ‘Index’.

What is GIT stash?

GIT stash takes the current state of the working directory and index and puts in on the stack for later and gives you back a clean working directory.  So in case if you are in the middle of something and need to jump over to the other job, and at the same time you don’t want to lose your current edits then you can use GIT stash.

How can you create a repository in Git?

In Git, to create a repository, create a directory for the project if it does not exist, and then run command “git init”. By running this command .git directory will be created in the project directory, the directory does not need to be empty.

To delete a branch what is the command that is used?

Once your development branch is merged into the main branch, you don’t need

development branch.  To delete a branch use, the command “git branch –d [head]”.

What is the function of ‘git rm’?

To remove the file from the staging area and also off your disk ‘git rm’ is used.

What is ‘git add’ is used for?

‘git add’ adds file changes in your existing directory to your index.

What is the function of ‘git reset’?

The function of ‘Git Reset’ is to reset your index as well as the working directory to the state of your last commit.

You may also like...

Leave a Reply

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