git hub(prep) mostly asked questions
git hub(prep) mostly asked questions
Profile
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.
Speed
Data integrity
Support for distributed
Non-linear workflow.
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.
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
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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”.
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.
Git rebase is performed when the main branch is a Git merge is performed when the main branch is
particular branch. a combined branch.
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
Git GitHub
Git should be installed locally in the system GitHub GitHub is hosted on the web
Git SVN
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.
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 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.
C programming language is used in Git. 50% of Git is written in the C programming language.
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.
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.
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
.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.
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.
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.
A broken comment can be fixed using the command “git commit -amend”.
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
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
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.
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.
Dashboards
Contact Us Accenture Microsoft Instagram
About Us Cognizant TCS CoCubes Dashboard Linkedin support@prepinst
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
https://prepinsta.com/interview-preparation/technical-interview-questions/github-interview-questions-and-answers/ 8/8