Top 50 GIT Interview Questions for SDET


The following set of frequently asked interview questions have been compiled to help students and professionals preparing for Certified SDET professional courses, SDET Foundation Training, Certified SDET Architect courses. You can see the full set of SDET Interview questions here.

1. What is GIT?

GIT is a Distributed Version Control System (DVCS) and Source
Code Management System (SCMS) which is used to track changes to a file and also
allows to revert back to any particular change.

It has the ability to handle small and large projects with efficiency and speed.

2. What is the difference between GIT and SVN?

The differences between GIT and SVN are as follows:

GIT is a Decentralized Version
Control tool.
SVN is a Centralized Version
Control tool.
The entire repository can be cloned on the local system.Version history is stored on a
server-side repository.
Commits are possible even if offline.Only online commits are allowed.
Push/Pull operations are faster.Push/Pull operations are slower.
Work is shared automatically on commit.Work is not shared automatically.

3. What are the advantages of GIT?

The advantages of GIT are as follows:

  • Data redundancy and data replication are possible.
  • Excellent network performance and disk utilization.
  • There is only one .git directory per repository.
  • Highly available service.
  • Any type of project can use GIT.
  • It is very easy to collaborate on any project.

4. What language is used in GIT?

C is the programming language that is used in GIT.

C ensures that the overhead of runtimes associated with high-level languages is reduced and hence making GIT faster.

5. What is a repository in GIT?

A GIT repository contains a directory named as .git where it keeps all of its metadata for the repository.

All the contents of .git directory are private to GIT.

6. Which command is used to write a commit message?

git commit -a is used to write a commit message in GIT.

The -a is used to instruct the git to commit the new content of all tracked files that have been modified.

If any new file needs to be committed for the first time, “git add<file>” is used before git commit.

7. What is Staging Area or Index in GIT?

Commits can be changed, formatted and reviewed in an intermediate area, before the completion of commits.

This intermediate area is called a Staging Area or Index.

8. What is the difference between Git Pull and Git Fetch?

  • git fetch downloads any new data from a remote repository but it doesn’t integrate this downloaded data into the working files.
  • git pull downloads and also merges the data from a remote repository into the working files.
  • It can merge conflicts as well if local changes are not committed.
  • git pull = git fetch + git merge

9. What is Git Stash?

Git Stash takes the current state of the working directory and
puts it on the stack for later and hence providing a clean working directory.

Git Stash is used when we need to switch to any other job and at the same time, we don’t want to lose our existing work.

10. What is Git Stash drop?

When we want to remove the stashed item from the list, then git stash drop command is used.

It removes the last added item in stash by default and it can also remove a specific item if included as an argument.

11. What is the use of git clone?

git clone command is used to create a copy of an existing GIT repository.

Git clone is the most common way used by programmers to get the copy of a central repository to a local workspace.

12. How to identify if a certain branch has been merged into master?

git branch –merged master : It shows all branches that are merged into master.

git branch –merged : It shows all branches that are merged into the head.

git branch –no-merged : It shows all branches that are not merged.

13. What is the function of git config?

The git config command is an easy way to set configuration options for GIT installations.

git config command is used to define the behaviour of a repository, user info, preferences, etc.

For eg.: We configure global username and email address after installing GIT. However, we can set them now if we missed that step or want to make changes.

git config –global “First_Name: This will add username.

git config –global “emailAddress” : This will add Email Address.

14. How can you create a repository in GIT?

To create a repository in GIT, create a directory for the project if it does not exist, and then run the command “git init”.

This command will create .git directory in the project directory, the directory does not need to be empty.

15. What is the purpose of branching in GIT?

Branching is used to create a new own branch till some commits and then can easily switch between those branches. GIT allows having multiple local branches that can be entirely independent of each other.

This will help to go to previous work keeping the recent work intact.

16. How can you delete a local and remote GIT branch?

To delete a local GIT branch, following command is used:

git branch -d branch_name

To delete a remote GIT branch, following command is used:

git push <remote_name> –delete <branch_name>

17. What is the difference between ‘git
remote’ and ‘git clone’?

‘git remote add’ just creates an entry into a git config that
specifies a name for a particular URL.

While, ‘git clone’ creates a new directory by copying the existing remote repository into a local workspace at the particular URL.

18. What is the function of ‘git diff’ in GIT?

‘git diff’ is used to show the changes between commits, commit and working tree, etc.

The most common scenario to use diff is to see what changes are made after the last commit.

For eg.:
git diff HEAD [filename]
: It compares the working directory with the local repository.

git diff [filename] : It compares the
working directory with Index.

git diff –cached [filename] : compare the index with local repository.

19. What is the function of ‘git checkout’ in GIT?

‘git checkout’ is a command that is used to update directories
or specific files in the working tree with those form another branch without
merging it in the whole branch.

The git checkout command operates upon three distinct entities:
files, commits and branches.

git checkout -b <new-branch>

20. What is the function of ‘git rm’ in GIT?

‘git rm’ command is used to remove individual files or a collection of files.

It is used to remove files from both the staging index and the working directory.

git  rm DLA/\*.txt : This will remove all .txt files that are children of DLA directory and any of its subdirectories.

21. What does ‘hooks’ consists of in GIT?

GIT hooks are Shell scripts that are executed before or after
the corresponding GIT commands, such as : commit, push and receive.

Git hooks are a built-in feature and there is no need to
download them.

For eg.: GIT will try to execute a post commit script after a run of the commit.

22. How can you fix a broken commit in GIT?

git command –amend command is used to fix a broken commit in GIT.

This command will fire the commit patch in $Editor. We just need to edit the message right on the top line of the file, save and then quit.

23. What is conflict in GIT?

A conflict in GIT arises when the commit that needs to be merged has some change in one file, and also the current commit has changed in the same place in that file.

In this case, GIT is not able to predict which change should take precedence.

24. What is ‘head’ in GIT and how many heads can be created in a repository?

A ‘head’ in a GIT is simply a reference to a commit object.

There is a default header referred to as “Master” in every repository.

A repository can contain any number of heads.

25. What is another option for merging in GIT and what is the syntax for the same?

‘Rebasing’ is an alternative of merging in GIT.


git rebase [new-commit]

26. What is ‘git add’ is used for in GIT?

‘git add’ is used to add file changes in the working directory to the staging area.

It tells GIT that certain updates to a particular file need to be included in the next commit.

git add <file> : Stage all changes in the
file for next commit.

git add <directory> : Stage all changes in directory for the next commit.

27. What is the use of ‘git log’ in GIT?

‘git log’ is used to find specific commits in the project history.

It can be searched by date, by author, by message, by file,

For eg.:

git log –after=“yesterday”

git log –author=”DLA”

28. What is the use of ‘git reset’ in GIT?

‘git reset’ is used undo all the changes in the local directory as well as in the staging area and resets it to the state of last commit.

git reset

29. What is GIT version control?

GIT version control is used to track the history of a collection of files and it also includes the functionality to revert the collection of files to another version.

Each version captures a screenshot of the file system at a certain point of time. All files and their complete history are stored in a repository.

30. Mention some of the best graphical GIT client for LINUX.

Some of the best GIT client for LINUX are:

  • Smart Git
  • Git Cola
  • qGit
  • Git-g
  • Giggle

31. What does commit object contain?

Commit object contains the following:

  • It contains a set of files that represent the state of a project at a given point of time.
  • It contains a reference to parent commit objects.
  • Additionally, it contains an SHAI name, a 40 character string that uniquely identifies the commit object.

32. What is Subgit and why subgit is used?

SubGit is a tool that is used for a smooth , stress-free SVN to GIT
migration. It is a solution for a company-wide migration from SVN to GIT.

It is widely used for following reasons:

  • It is much better than git-svn.
  • There is no requirement to change the infrastructure that is already placed.
  • It allows using all features of GIT and SVN.
  • It provides genuine stress-free migration experience.

33. What is ‘git status’ used for?

‘git status’ is used to display the state of the working directory and the staging area.

It allows us to see which changes have been staged, which have not been staged and which files aren’t being tracked by Git.


git status

34. What is the function of ‘git stash apply’?

‘git stash apply’ command is used to bring back the saved changes onto the working directory.

It is used when we want to continue working where we have left our work.


git stash apply

35. How git instaweb is used?

Git Instaweb automatically directs a web browser and runs webserver with an interface into your local repository.

36. How do you squash last N commits into a single commit?

Following command is used to squash the last N commits of the
current branch:

git rebase –i

N= no. of commits that you want to squash.

When the above command is run, an editor will open with a list of N commits message, one per line. Each of these lines begins with the word “pick”. Replacing the word “pick” with “squash” or “s” will tell Git to combine the commit with the commit before it. Hence set every commit in the list to be squash except the first one to combine all N commits into one.

37. How can you copy a commit made in one branch to another?

cherry-pick command is used to copy a commit from one branch to another.

It allows to playback an existing commit to current location or branch.

Simply switch to the target branch and call git cherry-pick {hash of that commit}.

38. How do you cherry-pick a merge commit?

cherry-pick uses diff to find the differences between branches.

Since merge commit belongs to a different branch, it has two
parents and two changesets.

For eg.:
If we have to merge commit ref 43ad64c, we have to specify -m and use parent 1 as a base:

git checkout release_branch

git cherry-pick -m 1 43ad64c

39. What is GIT Bisect and what is its purpose?

Git Bisect allows finding a bad commits efficiently.

Instead of checking every single commit to find the one that
introduced some particular issue into the code, git bisect allows the user to
perform a sort of binary search on the entire history of repository and hence
making it easier to find a bad commit.

This command uses a binary search algorithm to find which commit in the project’s history has introduced an issue. Before the introduction of issue, the commit is referred to as ‘good’ and after the introduction of issue, it is referred to as ‘bad’.

Then this command picks a commit between those endpoints and asks what kind of commit it is. This process continues till it finds the exact commit that introduced the change.

40. What commands will you use to bring a new feature to the main branch?

To bring a new feature to the main branch, we can use git
or git pull


git merge

git pull

41. What is the difference between ‘git diff’ and ‘git status’?

Git diff shows the differences between various commits and also between the working directory and staging area.

Git status provides not only the details of the files to be staged in the working repository but along with provides the status of the comparison with the origin of your branch.

42. How to resolve a conflict in GIT?

For resolving any conflict in GIT, we need to edit the files for fixing the conflicting changes and then we need to run ‘git add’ command to add the resolved files.

After that ‘git commit’ command needs to be run to commit the repaired merge.

43. What is meant by GIT fork?

A Git fork is simply a copy of a GIT repository.

Forking down a repository in GIT ecosystem enables to freely experiment with different changes with little or no effects on original project.

44. Name a few GIT repository hosting services.

Some of the popular GIT repository hosting services are:

  • GitHub
  • Bitbucket
  • GitLab

45. Describe various branching strategies.

Various branching strategies are as follows:

Feature Branching: A feature branch keeps all the changes for a particular feature inside a branch. When the feature is fully tested and validated, then it is merged into master.

Task Branching: In Task branching, each task is implemented on its own branch with the task key included in the branch name. With this, it is easy to see which code implements which task, just need to find the task key in the branch name.

Release Branching: We can clone a branch to form a release branch once the develop branch has acquired enough features for a release. Creating the release branch starts the next release cycle, and hence no new feature can be added after this point, only bug fixes are allowed.

46. Why GIT is better than SVN?

GIT is an open-source version control system, it allows to run versions of a project, which shows the various changes that were made to the code overtime.

It also allows to keep the backtrack if necessary and undo
those changes.

In GIT, multiple developers can checkout, and upload changes and then each change can be attributed to a specific developer.

47. What is git Is-tree?

Git Is-tree is used to represent a tree object including the mode and name of each item and also SHA-1 value of the blob or the tree.

48. What is the function of ‘git push’ in GIT?

‘git push’ command is used to update new local commits on a remote repository.

git push

49. Why is it advisable to create an additional commit rather than amending an existing commit?

It is always advisable to create an additional commit rather
than amending an existing commit because the amend operation will destroy the
state that was previously saved in a commit.

If only the commit message needs to be changed, then it’s not an issue to amend but if the contents are being amended, then there are more chances of eliminating some important content.

50. What does git pull origin master do?

A git pull origin master is used to pull the master branch from
the remote repository called origin into your current branch.

This only affects the current branch and not the local master branch.

More SDET Interview Question by Devlabs Alliance


Related Articles
Latest Articles

Popular Courses

Google Reviews
  • review rating 5  Excellent Training program. Training courses and trainers are very good. Trainer will explain you as many time you ask the question. Best thing is hands on based training. You learn by doing. Looking for more courses from here.

    thumb Vijay Kumar
  • review rating 4  Both trainers (Ravi and Naresh) were excellent in their approach. Session was less of a theory and more of a practical. And even the theory part was quite interesting. A bit issue with the volume of information which I had received in just a span of 2-3 days - it seemed a bit over-loaded. But overall, it has given me a great platform to take it forward from here!

    thumb Varenya Varshney
  • review rating 5  Training provided by the trainers here is completely awesome. Trainer is highly qualified in their areas with practical experience. Also amenities provided during training by institute is great

    thumb Abhishek Tripathi
  • review rating 4  Training provided by the trainers in DevLabs Alliance is completely awesome. Trainers are highly qualified in their areas with practical experience. Since it is 3 days training we have completely got the opportunity to have hands on.

    thumb Salaja K
  • review rating 4  It was good session, I left my training room with basic knowledge on all the tools. Tutors have great knowledge and experience on the tools. But three days is not enough time.

    thumb sairam shyamala
$('.enrollbtn').on('click', function (){ $( "#announcement" ).tabs( "option", "active", 0 ); $(' a[href="#announcement"]').trigger('click'); });