Interview Questions - Top 30 Git Interview Questions and Answers
Interview Questions - Top 30 Git Interview Questions and Answers
Login
Answer:
Git is a version control system of distributed nature that is used to track changes in source code during software development. It is
used for coordinating work among developers in project. It can also be used to track changes in any set of files. The main objectives of
Git are speed, data integrity, and support for distributed, non-linear workflows.
GitHub is a Git repository hosting service, plus it adds many of its own features. GitHub provides a Web-based graphical interface. It
also provides access control and several collaboration features, basic task management tools for every project.
Answer:
a) With the Version Control System(VCS), all the team members can work freely on any file at any time. VCS gives the flexibility to
merge all the changes into a common location.
b) All the previous versions and variants are neatly packed up inside the VCS. We can request any version at any time as per our
requirement and we will have a snapshot of the complete project right at hand.
c) Whenever we save a new version of our project, our VCS requires a short description of the changes that we have made. Additionally,
we can see what changes are made in the file’s content. This helps us to know what changes have been made in the project and by
whom and when those changes were made.
d) A distributed VCS like Git allows all the team members to have a complete history of the project so if there is a breakdown in the
central server you can use any of your teammate’s local Git repository.
Answer:
git clone
git status
git push
git pull
git log
git rm
git checkout
git fetch
git branch
Answer:
Message Us
Git Repository is a place where we will store/maintain our project source code.
We can 2 types of repositories in git hub
1) Public Repository (Every body can see, we choose who can commit)
2) Private Repository (We choose who can see and who can commit)
Answer:
Cloning in a GitHub repository is nothing but taking project from git hub central repository to our local repository.
6) What are the commands that you use to write a commit message?
Answer:
Note: Commit message represents why we are commiting this change to git repository
Answer:
GIT stash is used when there is a need of storing the current changes available in working tree to temporary space and work on other
changes due to priority. Once priority changes completed then user can get old changes back from temporary space.
Answer:
git status command is used to list down stated and un-staged files in working tree
Answer:
un-staged file means which is modified in local but not eligible for commit.
Answer:
The following are the few advantages of using the GitHub repository;
Answer:
GitHub is a fast tool and ‘C’ language makes this possible by reducing the overhead of runtime associates with the higher programming
language. Message Us
12) What is the role of “Git push”?
Answer:
The “Git push” command is used for pushing changes from local repository to central repository.
Answer:
The “Git pull command is used for taking latest changes from central repository to local repository
Answer:
Answer:
When we do commit in git it will generate one unique id with 40 characters length to differentiate one commit with another commit.
Using commit-id we can identify what all changes committed to git repository.
Answer:
To remove a file from git repository we can use "git rm" command.
Answer:
Git branches are used to maintain multiple code bases in the project like 'develop', 'qa', 'uat', 'release', 'playground' etc.
Answer:
When we release code to SIT or UAT or PROD we will lock the branch so that nobody can commit changes to that branch so that
existing functionality or code will not be disturbed.
Answer:
Merging changes from one branch to another branch is called as branch merging. For example we have done changes in develop
branch and tested then we can merge the code from develop branch to master branch.
Answer:
Message
Yes, while merging code from one branch to another branch i have faced conflicts and i resolved conflicts then i merged my code from Us
develop branch to master branch.
21) What is the GIT stash drop?
Answer:
git stash drop command is used to remove all stashes available in git.
22) What is "git log" and when you can use it?
Answer:
The Git log command is used to find the history of commits happend in git repository. Using that history we can identify who, when, why
& what changed in git repository.
Answer:
When we are pushing/merging changes to git repository there is a chance of getting git conflicts.
Git can handle most merges on its own with automatic merging features. 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.
Answer:
a) Make the necessary changes in the files so that conflict does not arise again
Answer:
Answer:
Git uses your username to associate commits with an identity. The git config command can be used to set your user-name and email-
id.
Suppose you want to give a username and email id to associate a commit with an identity so that you can know who has made a
particular commit
git config –global user.name “Your Name”: This command will add a username.
git config –global user.email “Your E-mail Address”: This command will add an email id.
27) Which client software you are using to interact with git repository?
Answer:
Git bash
Git GUI
Answer:
Approach-1 : Remove or edit the changes in the file in a new commit and then push it to the remote repository. This is the most obvious
way to fix an error. Once we have made required changes then commit that file to the remote repository using : git commit -m “commit
message”Also, you can create a new commit that undoes all changes that were made in the bad commit.
29) What is the difference between git pull and git fetch?
Answer:
Git pull command pulls new changes or commits from a particular branch from your central repository and updates your target branch
in your local repository.
Git fetch is also used for the same purpose but it works in a slightly different way. When you perform a git fetch, it pulls all new commits
from the desired branch and stores it in a new branch in your local repository. If you want to reflect these changes in your target branch,
git fetch must be followed with a git merge.
Your target branch will only be updated after merging the target branch and fetched branch. Just to make it easy for you, remember the
equation below:
30) What is the difference between git pull and git clone ?
Answer:
"git clone" is used to take entire project from central repository to local repository
"git pull" is used to take only latest changes/commits from central repository to local repository
Message Us
Ashok IT is a leading Indian IT training institute preparing tech-aspirants for flourishing careers in this challenging and competitive
domain since 2020.
QUICK LINKS
About us
Online Batches
Classroom Batches
Weekend Workshops
Contact us
OUR SERVICES
Online Training
Classroom Training
Corporate Training
Placements
Internship
Legal
Terms of use & Privacy Policy
Contact Us
Message Us
+91 9985396677 [email protected]
H.No - 7-1-413/2, Beside Sonabhai Temple, Ameerpet, Hyderabad - 500016
Follow Us
Message Us