Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
48 views

Basic Git Interview Questions

Git is an open-source version control system that allows developers to track changes to code over time and collaborate on projects. When a developer makes a change, they can commit it locally and then push the change to a remote repository, where other developers can pull the changes. Git is free and open to anyone. It is commonly used for software development but can track changes to any files.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Basic Git Interview Questions

Git is an open-source version control system that allows developers to track changes to code over time and collaborate on projects. When a developer makes a change, they can commit it locally and then push the change to a remote repository, where other developers can pull the changes. Git is free and open to anyone. It is commonly used for software development but can track changes to any files.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

What Is Git and Why Is It Used?

Git is an open-distributed version control system that allows developers to track changes to their
codebase and collaborate on projects with other developers. Git is typically used for software
development, but it can be used for any type of file.

When a developer makes a change to a code file, they can commit that change to their local Git
repository. Then, they can push their changes to a remote Git repository, such as a server hosted by
a company or an open-source project. Other developers can then pull the changes down from the
remote repository and incorporate them into their code.

And an important thing about Git is that it is a free source and open to anyone.

Basic Git Interview Questions


1. What is Git?

Git is a version control system for tracking changes in computer files and is used to help coordinate
work among several people on a project while tracking progress over time. In other words, it’s a tool
that facilitates source code management in software development.

Git favors both programmers and non-technical users by keeping track of their project files. It
enables multiple users to work together and handles large projects efficiently.

2. What do you understand by the term ‘Version Control System’?

A version control system (VCS) records all the 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
3. What is GitHub?

To provide Internet hosting for version control and software development, GitHub makes use of Git.

4. Mention some popular Git hosting services.

GitHub

SourceForge

GitLab

Bitbucket

5. Different types of version control systems

Local version control systems have a database that stores all file changes under revision control on
disc in a special format.

Centralized version control systems have a single repository, from which each user receives their
working copy.

Distributed version control systems contain multiple repositories, and different users can access
each one with their working copy.

6. What benefits come with using GIT?

Data replication and redundancy are both possible.

It is a service with high availability.

There can only be one Git directory per repository.

Excellent network and disc performance are achieved.

On any project, collaboration is very simple.

7. What’s the difference between Git and GitHub?

Git GitHub

Git is a software GitHub is a service

Git can be installed locally on the system GitHub is hosted on the web

Provides a desktop interface called


Provides a desktop interface called git GUI
GitHub Desktop.
It does not support user management features Provides built-in user management

8. What is a Git repository?

Git repository refers to a place where all the Git files are stored. These files can either be stored on
the local repository or on the remote repository.

9. How can you initialize a repository in Git?

If you want to initialize an empty repository to a directory in Git, you need to enter the git init
command. After this command, a hidden .git folder will appear.

10. How is Git different from Subversion (SVN)?

GIT SVN

SVN is a centralized version control


Git is a distributed decentralized version control system
system.

Git stores content in the form of metadata. SVN stored data in the form of files.

In SVN, the trunk directory has the


The master contains the latest stable release.
latest stable release

The contents of Git are hashed using the SHA-1 hash algorithm. SVN doesn’t support hashed contents.
11. 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

12. What are the advantages of using Git?

Faster release cycles

Easy team collaboration

Widespread acceptance

Maintains the integrity of source code

Pull requests

13. What language is used in Git?

Git is a fast and reliable version control system, and the language that makes this possible is ‘C.’

Using C language reduces the overhead of run times, which are common in high-level languages.

14. What is the correct syntax to add a message to a commit?

git commit -m "x files created"

15. Which command is used to create an empty Git repository?

git init - This command helps to create an empty repository while working on a project.

16. What does git pull origin master do?

The git pull origin master fetches all the changes from the master branch onto the origin and
integrates them into the local branch.

git pull = git fetch + git merge origin/ master

After having gone through the beginner level Git interview questions, let us now look at
intermediate GIT interview questions and answers.
Intermediate Git Interview Questions

17. What does the git push command do?

The Git push command is used to push the content in a local repository to a remote repository. After
a local repository has been modified, a push is executed to share the modifications with remote
team members.

18. Difference between git fetch and git pull.

Git Fetch Git Pull

Git pull updates the current HEAD


The Git fetch command only downloads new data from a remote
branch with the latest changes from
repository.
the remote server.

Downloads new data and integrate it


It does not integrate any of these new data into your working files.
with the current working files.

Tries to merge remote changes with


Command - git fetch origin
your local ones.
git fetch --all
Command - git pull origin master

19. GitHub, GitLab and Bitbucket are examples of git repository _______ function?

hosting. All the three are services for hosting Git repositories

20. What do you understand about the Git merge conflict?

A Git merge conflict is an event that occurs when Git is unable to resolve the differences in code
between the two commits automatically.
Git is capable of automatically merging the changes only if the commits are on different lines or
branches.

You might also like