Introduction to GIT Interview Questions and Answers
GIT is the source code management (SCM) system, which is used to track the changes and central system to commit the changes for different programmers. It was created by Linus Torvalds in the year 2005. It was written in C, shell, Perl, TCL, and python. It is available in English. It supports different operating systems like Linux, Windows and Mac OS. Git is free and open-source software. It is mainly referred to as a distributed version control system.
Now, if you are looking for a job which is related to GIT then you need to prepare for the 2020 GIT Interview Questions. It is true that every interview is different as per the different job profiles. Here, we have prepared the important GIT Interview Questions and Answers which will help you get success in your interview. These questions will help students build their concepts around GIT and help them ace the interview.
Part 1 – GIT Interview Questions (Basic)
This first part covers basic GIT Interview Questions and Answers.
Q1. Define GIT and repository in GIT?
GIT is version control system or distributed VCS to use for different projects and programmers to centralize the code of particular project at one place. The repository in GIT consists of a directory named .git, in which it keeps all the data for the repository. The content remains private to git. GIT is recommended to use as it can be used for any project without any restrictions.
Q2. Difference between GIT and SVN?
GIT is referred to as distributed control version system and SVN is referred as centralized version system. While working with GIT, the code can be taken once in your local machine and changes can be done and committed, and an end, the whole can be committed in one go to master branch. It means it does not require connected with a network for check in the code all the time. While working with SVN, it needs to be connected with the network when any code needs to be committed.
Let us move to the next GIT Interview Questions.
Q3. Mention GIT commands that are mainly used?
There are some commands that are mostly used:
- GIT status: To know the comparison between the working directories and index.
- GIT diff: to know the changes between the commits and the working tree.
- GIT stash applies: to get the saved changes on the working directory.
- GIT log: to know specific commit from the history of commits.
- GIT add: It adds file changes in an existing directory to index.
- GIT rm: It removes a file from the staging area.
- GIT init: creating a new repository.
- GIT clone: to copy or check out the working repository.
- GIT commit: committing the changes.
- GIT PUSH: sending the changes to the master branch.
- GIT pull: fetch the code already in the repository.
- GIT merge: merge the changes on the remote server to the working directory.
- Git reset: to reset or drop all the changes and commits.
Q4. Explain the purpose of branching and its types?
This is the basic GIT Interview Questions asked in an interview. In Git, the branching is done to allow the user to create their own branch and toggle between those branches. It allows the user to switch between the branches to keep the current work in sync without disturbing master branches and other developer’s work as per their requirements. There are 3 types of branching: Feature branching, Task branching, and Release branching. Feature branching keeps all the changes in the branch and when the feature is completely tested and validated merged into master. Task branching included its own branch with task key included in branch name. Release branching, it develops the branch acquires enough feature for a release the user can clone that branch to form releasing branch.
4.5 (2,388 ratings)
Q5. How do you resolve ‘conflict’ in GIT?
When one developer takes the code from GIT in the local system and does the change and tries to commit that code but already another developer has committed the changes. At that point, conflict arises while committing the change. To resolve the conflict in GIT, files need to be edited to fix the conflicting changes and then add the resolved files by running the GIT add command and commit the repaired merge. GIT identifies the position and sets the parents to commit correctly.
Part 2 – GIT Interview Questions (Advanced)
Let us now have a look at the advanced GIT Interview Questions.
Q6. Explain Git stash and Git stash drop?
Git Stash takes the current state of working directory and index. It pushes into the stack for later and returns cleaning the working directory. It helps in instances the work in the project and switches the branches to work. Git stash drop is used when you are done and want to eliminate the stashed item from the list, then running the GIT stash drop command will remove last added stash item by default and can also remove the specific item if any argument is included or mentioned.
Q7. What is GIT bisect and its purpose?
GIT bisect command is the command which is used to find that commit which has invoked bug by using binary search. This command uses the binary search algorithm to find the commit, which has a bug and it is referred to as bad commit. Before the bug has been introduced, it was referred to as good commit. This command will search the commit between the endpoints until it finds the exact commit, which introduced the change or bug.
Let us move to the next GIT Interview Questions.
Q8. What are the advantages of using GIT?
The advantages of using GIT are High availability, data redundancy and replication, only one .git directory per repository, collaboration-friendly, disk utilization, and network performance, any project can be used in GIT (small or large), scalability, easily integrated with other tools like Jenkins etc.
Q9. Explain head in git?
This is the frequently asked GIT Interview Questions in an interview. A head in GIT is referred as commit object. Master is referred to as the default head in every repository. The repository can contain any number of head.
Q10. Explain SubGit and its use?
SubGit is a tool for smooth, stress-free SVN to GIT migration. It is a solution for company-wide migration from SVN to GIT. It is better than git-svn, no requirement to change the infrastructure that is already placed allows using all git and svn features, and provides genuine free migration experience.
Q11. How to rebase master in GIT?
Rebasing is defined as the process of moving a branch to a new base commit. The rule of git rebase is to never use it on public branches. To synchronize two branches is to merge them together, which results in extra merge commit and two sets of commits will contain the same changes.
This has been a guide to list Of GIT Interview Questions and Answers so that the candidate can crackdown these GIT Interview Questions easily. Here in this post, we have studied top GIT Interview Questions which are often asked in interviews. You may also look at the following articles to learn more –