0% found this document useful (0 votes)
2 views

git hub(prep) mostly asked questions

The document provides a comprehensive list of the 31 most commonly asked GitHub interview questions and answers for freshers in 2023. It covers key concepts such as version control systems, Git commands, and differences between Git and GitHub, along with practical commands and their functionalities. The content serves as a preparation guide for candidates looking to enhance their understanding of Git and GitHub for technical interviews.

Uploaded by

pavan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

git hub(prep) mostly asked questions

The document provides a comprehensive list of the 31 most commonly asked GitHub interview questions and answers for freshers in 2023. It covers key concepts such as version control systems, Git commands, and differences between Git and GitHub, along with practical commands and their functionalities. The content serves as a preparation guide for candidates looking to enhance their understanding of Git and GitHub for technical interviews.

Uploaded by

pavan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

2/25/23, 8:30 PM 31 Most Asked GitHub Interview Questions | Technical Interview | PrepInsta

 Profile

GitHub Interview Questions and Answers for freshers

Most asked GitHub Interview Questions for

Freshers 2023

Find the most asked GitHub Interview Questions and Answers on this page.

Page Highlights:

What is Git?
Top 31 GitHub Interview Questions

 Table of Content

Introduction to Git

Git is an open-source and free distributed version control system that helps the programmer to keep a track of changes that were made
to the projects and enables multiple users to work together on non-linear development and handle the large project efficiently. Git is a
DevOps tool mainly used for source code management.

The main objectives of Git:

Speed
Data integrity
Support for distributed
Non-linear workflow.

Commonly asked GitHub Interview Questions

1. Define Version Control System(VCS)?

A version control system is defined as a system that keeps all records of the changes made on a specific
project, and also helps us to ensure whether all developers in a team are working on the same or not. It
manages the history of all the activities done so, it gives a developer the confidence to fix a bug or make any
changes or run a test so if anything goes wrong previous work can be restored anytime.

2. What is GitHub?

GitHub is defined as the Git repository hosting service platform used for software development. It helps us to
work on projects and collaborate with other developers at any moment from anywhere.

3. What is git pull and git push?

Git pull: Git pull command refers to a command which helps to fetch and integrate modifications in the contents
from the remote repository to the local repository. To make it easy for you to understand we can remember this
equation:
7

Git pull = Git fetch+Git merge

https://prepinsta.com/interview-preparation/technical-interview-questions/github-interview-questions-and-answers/ 1/8
2/25/23, 8:30 PM 31 Most Asked GitHub Interview Questions | Technical Interview | PrepInsta

In other words, git pull is the combination of git fetch and git merge.

Command: git pull <remote> <branch>

Git push: Git push is the opposite of git pull in which the command is used to transfer the content of the local
repository into the remote repository.

Command: $git push <option> [<Remote URL><branch name><refspec>…]


4. What is the difference between git pull and git fetch?

Git Pull Git Fetch

Git pull command will retrieve all the information on Git fetch command is used to provide information
new changes in the content from the remote on new changes from the remote repository to the
repository to the local repository by merging with the local repository without merging with the existing
existing branch. branch.

Command: git pull . Command: git fetch

Git pull command’s main function is to fetch as well Git fetch command function is to fetch the new
as merge with the new modifications. modifications.

Repository data is updated in the local repository as Repository data is updated directly keeping the
well as the remote repository. remote repository unmodified.

5. What is the function of git annotate?

Git annotate function:

The main function of git annotate is to observe every activity such as modifications of the data in the file
introduced with the executed information.
Git annotate command optionally annotates from a provided revision of the file.

Command used: git annotate [<options>]<file>[<revision>]

6. What are git clone and git remote?

Git clone: Git clone command helps to create a duplicate or copy of an existing file in the remote repository
which will help you to make modifications in the local repository instead of modifying the file from the remote
repository.

Command used: $ git clone -b

Git Remote: Git remote command helps you to create, delete, and view connections between remote and local.
To view the original file of the copied repository, use the git remote command as

Command used: $ git remote

7. What are git revert and git reset?

Git Revert: Git revert command is an undo operation that is carried out if we make any mistakes in the commit. It
helps to find out how to reverse changes in the commit and the resultant is added as a new commit.
https://prepinsta.com/interview-preparation/technical-interview-questions/github-interview-questions-and-answers/ 2/8
2/25/23, 8:30 PM 31 Most Asked GitHub Interview Questions | Technical Interview | PrepInsta

Git reverse helps in the prevention of losing history from the Git. It is a secure alternative to git reset with
concerns about losing work.

Command: $ git revert

Git Reset: Git Reset command is a command that is used to revise and undo changes in a branch. The
disadvantage of using the reset command is that the history will get changed.

Command: $ git reset <option><commit-sha>

8. Define the commit message.

Commit: It is described as a saved message. A commit message tells the edits that are made in the project.

9. What do you mean by the Git repository? How do you create a Git repository?

Git repository:

A repository in Git is a place where workflow is securely stored. It is considered a task folder where the task
is saved in a directory called the .git repository folder.
Git repository uses a version control system to monitor the modifications made on a particular project and
save them into the .git repository folder which eases the user to make future changes.

Developing a git repository:

To develop a repository in git, use the command “git init” on the created project directory. If the directory of the
project is not created then you need to create a new directory and then run the command “git init”.

10. How git rebase is different from git merge?

Git rebase Git merge

Logs are linear in Git rebase which means it won’t show Logs are non-linear which means logs will show
the complete history of merging occurring. all the merging history that occurred.

It is a multi-stage operation. It is a one-step operation.

Git rebase is performed when the main branch is a Git merge is performed when the main branch is
particular branch. a combined branch.

Command used: $git rebase Command used: $git merge

https://prepinsta.com/interview-preparation/technical-interview-questions/github-interview-questions-and-answers/ 3/8
2/25/23, 8:30 PM 31 Most Asked GitHub Interview Questions | Technical Interview | PrepInsta

11. What is the difference between Git and GitHub?

Git GitHub

Git is software. GitHub is a service.

Git is a Command-Line interface. GitHub is a Graphical User interface.

Git is Maintained by Linux GitHub is Maintained by Microsoft

No user management feature. User management feature available.

Git is open-sourced license GitHub includes free and pay-for-use features.

Git should be installed locally in the system GitHub GitHub is hosted on the web

12. Distinguish between Git and SVN.

Git SVN

Git is a distributed model SVN is a centralized model

Difficult to learn. Easy to learn when compared to Git

In Git, the .git directory is created by us. In SVN, the .svn directory is created for each
folder

Git doesn’t have a good User Interface when compared to SVN has a good User Interface
SVN

13. List out the Git commands and explain their roles.

Listing out the most common commands used in Git.

https://prepinsta.com/interview-preparation/technical-interview-questions/github-interview-questions-and-answers/ 4/8
2/25/23, 8:30 PM 31 Most Asked GitHub Interview Questions | Technical Interview | PrepInsta

Git commands Role

git diff Display the changes made in a project

git config Install the email and name of the creator.

git add To add new files in the staging area.

git commit Commit all modifications to the head, not to the remote repository.
14. What is the function of the git cherry-pick command?

git main
The init function of the cherry-pick command
CreatesinanGit
empty repository
allows to selectincommits
a specificfrom
directory.
one branch in a repo and
added in the existing branch. This process is helpful to undergo undo process if something goes wrong during an
operation.
git clone Make a copy of data from the remote repo and locate it in the local repository.

Command used: $git cherry-pick <commit id>


git fetch Fetching the data without merging with the existing branch
15. Name the language used in Git.

C programming language is used in Git. 50% of Git is written in the C programming language.

16. What is the function of git reflog?

The main functionality of git reflog is to keep track of updates to the tip of branches using a mechanism called
reflog. The reflog is also known as the reference log.

17. What is the functionality of git Is-tree?

The main purpose of the git Is-tree command is to record the contents of a tree object.

18. What is the difference between Head, Working Tree, and Index in Git?

Head: The Head is the parent of the next commit that is created. It is a pointer to the current branch reference
and also a pointer to the last commit on the branch.
Working Tree: The working tree is where your files reside and also you can try changes before committing. It
is to record the snapshots of the project.
Index: The index is a staging area between the working directory and repository. It is used to build a set of
changes that you want to commit together.

19. What are the advantages of using Git?

The main advantages of using Git are:


Showcase your work: One can show his/her hard work by using Git. This helps many of the students to get
placed since all recruiters are finding through Git.

Performance: It is very flexible when compared to older versions.

Security: Git uses an algorithm called SHA 1 that protects the code and change history against accidental
changes or malicious damage.

Wide Acceptance: Git is the most widely accepted system as it has universally accepted usability and
performance standards.

https://prepinsta.com/interview-preparation/technical-interview-questions/github-interview-questions-and-answers/ 5/8
2/25/23, 8:30 PM 31 Most Asked GitHub Interview Questions | Technical Interview | PrepInsta

20. What happens when the .git directory gets deleted?

.git directory is an important element in Git that stores all the reports related to the commits, remote repo
address also maintains a record of all the commit history which will help you to retrieve any code whenever
needed.

However, deleting the .git folder won’t delete the files contained in the folder eventually, lose track of your
project’s history. the folder will no longer be included in versioning control.

21. What is the command used to write a commit message?

Command used: $git commit -m “<commit message>”.

22. What is Git architecture?

Git is a three-tier architecture and it consists of three layers. They are


Working directory
Staging area
Local repository

23. What is the use of staging area or indexing in Git?

One can add and remove changes from the staging area. It is considered the real area where git stores the
changes.

24. Write down the command used to create an empty Git repository.

The command used to create an empty Git repository is “git init”. It is used to create a new repository.

25. How git status is different from git diff?

Git Status: Git Status Shows the difference between the working directory and index.

Git Diff: Git Diff Shows the changes between commits and the working directory.

26. How to fix a broken commit?

A broken comment can be fixed using the command “git commit -amend”.

27. List the different Git repository hosting functions.

Different hosting functions on the git repository are


GitHub
GitLab
SourceForge
Bitbucket
Visual studio team
Beanstalk

28. What is the main role of command git config?

The Git config command is a command used to check the configuration for your git installation and also
maintains the git looks and functions.

Also useful while Installing the email and name of the creator.
https://prepinsta.com/interview-preparation/technical-interview-questions/github-interview-questions-and-answers/ 6/8
2/25/23, 8:30 PM 31 Most Asked GitHub Interview Questions | Technical Interview | PrepInsta

Command used: $git config

29. How do we revert a commit which is already been pushed?

The steps involved to revert a commit which is already been pushed are
1. Move to the Git history
2. Right-click on the commit that you want to revert
3. Select revert commits
4. Ensure the commit the change is reviewed
5. Click on revert

30. How to recover a deleted branch in Git?

Recover a deleted branch in Git:


On github.com, navigate to the repository of the main page.
Click pull requests under your repository name.
Click on “closed” to see the closed pull requests.
Click the pull request associated with the branch, you want to restore.
Click “Restore branch” at the bottom of the pull request.

31. Define conflict in Git and how to fix it.

Git Merge Conflict: It is an event that takes place when Git is unable to resolve differences in code between two
commits automatically. If the commits are on different lines or branches then git can merge the changes
automatically.

Example: If two developers X and Y are working on the same file from the remote repository. And each of them
wants to make changes. If X makes some changes and pushes the file back to the remote repository from the
local repository. Now, when Y tries to push that file after making changes from his end, he is unable to do so,
because the file has already changed to the remote repository.

To avoid this conflict, the Git merge command combines separate branches and resolves any conflicting edits.

Fixing the conflict:

One has to make necessary changes to resolve the conflicted file by opening it.
After the changes or editing, use the git add a command to stage the new merged content.
Create a new commit with the help of the git commit command.
Git will create a new merge commit to finalize the merge.

Also Check: Most Asked Technical Interview Questions

Support Companies All Exams Get In Touch Get In Touch

Dashboards
Contact Us Accenture Microsoft Instagram
About Us Cognizant TCS CoCubes Dashboard Linkedin support@prepinst

Refund Policy MindTree Infosys eLitmus Dashboard Youtube a.com


PrepInsta.com
Privacy Policy VMware Oracle HirePro Dashboard +91-8448440710

https://prepinsta.com/interview-preparation/technical-interview-questions/github-interview-questions-and-answers/ 7/8
2/25/23, 8:30 PM 31 Most Asked GitHub Interview Questions | Technical Interview | PrepInsta

No.1 and most visited website for Services CapGemini HCL MeritTrac Dashboard Telegram Text us on

Disclaimer Deloitte TCS Ninja Mettl Dashboard facebook Whatsapp/Instagr


Placements in India.
Terms and Wipro IBM DevSquare Dashboard Twitter am

We help students to prepare for Conditions

placements with the best study


material, online classes, Sectional
Statistics for better focus
and Success stories & tips by
Toppers on PrepInsta.

© 2022 Prep Insta

Privacy Policy | Copyright © 2022 Prep Insta

https://prepinsta.com/interview-preparation/technical-interview-questions/github-interview-questions-and-answers/ 8/8

You might also like