Question library

Git interview questions and answers

45 Git interview questions with answers: 10 junior, 15 mid-level and 20 senior. Junior answers are free to read.

Junior Mid Senior Updated How these answers are created

* View counts were reset on 18 October 2026, when Interviewplus moved to interviewplus.app. Votes were not affected.

Answer

Git is a distributed version control system that enables developers to keep track of changes made to their codebase over time. It allows multiple developers to collaborate on a project and keep track of the changes made by each person.

Developers use Git for several reasons:
1. Version Control: Git tracks changes to a codebase and allows developers to revert to a previous version if needed. This helps to avoid data loss and makes it easy to collaborate with other developers.
2. Collaboration: Git enables developers to work on the same codebase simultaneously without worrying about conflicts. Each developer can make changes to their own copy of the codebase and then merge their changes with the master copy.
3. Branching and Merging: Git allows developers to create separate branches of a codebase for testing or experimenting. Once the changes are tested and ready, they can be merged back into the master branch.
4. Backup: Git allows developers to keep a backup of their codebase in a remote repository, which can be accessed from anywhere. This helps to avoid data loss due to hardware failures or accidents.
Overall, Git is an essential tool for developers, as it makes it easy to manage code changes, collaborate with others, and ensure that code changes are safe and secure.

Answer

Git and GitHub are related but distinct concepts. Git is a distributed version control system, while GitHub is a web-based hosting service for Git repositories.
Git is a software tool that runs locally on a developer's computer, which allows developers to track changes to their codebase and collaborate with others. Git does not require any internet connection or online platform to work.
On the other hand, GitHub is an online platform that hosts Git repositories and provides additional features such as issue tracking, pull requests, and wikis. GitHub allows developers to store their codebase in a remote repository that can be accessed from anywhere with an internet connection. GitHub also provides tools for collaboration, code review, and project management, making it a popular platform for open-source projects.
In summary, Git is a version control system that runs locally on a developer's computer, while GitHub is a web-based hosting service for Git repositories. While Git is the underlying technology that enables version control, GitHub provides additional features and tools to manage projects and collaborate with others.

Answer

Sure, here are the steps to create a Git repository, initialize it with a README file, and add and commit a new file to the repository:
1. Create a new directory on your local machine where you want to store the repository. You can do this through the terminal or using your file manager.
2. Open a terminal window in the new directory and run the following command to initialize a new Git repository:

git init

This will create a new Git repository in the current directory.
3. Create a new file in the repository directory using your text editor or file manager. For example, you can create a file called example.txt.

4. Add the file to the Git repository using the following command:

git add example.txt

This will stage the file to be committed.
5. Commit the file to the repository using the following command:

git commit -m "Add example.txt"

This will create a new commit with the message "Add example.txt" and include the file in the repository.
6. You can also create a README file using your text editor or file manager and then commit it to the repository using the same steps above. To create a README file through the terminal, you can run the following command:

echo "# My Project" > README.md

This will create a new README file with the contents "# My Project".

Answer

Sure, here's a basic Git workflow that involves creating a new branch, making changes, and merging those changes back into the main branch:
1. Create a new branch: The first step is to create a new branch in your Git repository. You can do this by running the command "git checkout -b new-branch-name". This will create a new branch called "new-branch-name" and switch you to that branch.
2. Make changes: Once you're on the new branch, you can make changes to your codebase as needed. You can add new files, modify existing ones, and delete files that are no longer needed.
3. Commit changes: After making changes to your codebase, you'll need to commit them to the repository. You can do this by running the command "git add ." to add all the changes to the staging area, followed by "git commit -m 'commit message'" to commit the changes to the repository.
4. Push changes: Once you've committed your changes, you can push them to the remote repository by running the command "git push origin new-branch-name". This will push the changes to the remote repository on the new branch.
5. Review changes: If you're collaborating with others on the project, they can review the changes you've made on the new branch by checking out the branch and reviewing the code changes.
6. Merge changes: Once the changes on the new branch are reviewed and tested, you can merge them back into the main branch. To do this, switch back to the main branch by running "git checkout main" and then run "git merge new-branch-name" to merge the changes from the new branch into the main branch.
7. Resolve conflicts: If there are conflicts between the changes made on the new branch and the main branch, Git will prompt you to resolve them. You'll need to manually review and resolve any conflicts before the merge can be completed.
8. Commit and push merged changes: Once the conflicts are resolved, commit the merged changes with "git commit -m 'merge commit message'" and push them to the remote repository with "git push origin main".
And that's it! This basic Git workflow can be used to manage changes to your codebase and collaborate effectively with others on your team.

Answer

When you merge changes from one branch into another, Git may detect conflicts between the changes made on the two branches. A merge conflict occurs when the same file or code block is modified in different ways on both branches. Resolving merge conflicts is an essential skill for any developer working with Git.
Here are the steps to handle merge conflicts in Git:
1. Identify the conflicted file(s): When you attempt to merge changes from one branch into another, Git will display an error message indicating which file(s) have conflicts. You can use the command "git status" to see which files have conflicts.
2. Open the conflicted file: Open the file(s) that have conflicts using a code editor or text editor. The conflicted parts will be marked with Git conflict markers "<<<<<<<", "=======", and ">>>>>>>". These markers indicate the conflicting changes made on each branch.
3. Resolve the conflicts: Edit the conflicted parts of the file(s) to resolve the conflicts. You'll need to decide which changes to keep and which to discard. Once you've resolved the conflicts, remove the Git conflict markers from the file(s).
4. Add and commit changes: After resolving the conflicts, stage the conflicted file(s) using the "git add" command and then commit the changes using the "git commit" command.
Here's an example of when you might encounter a merge conflict:
Let's say you're working on a project with a colleague. You both make changes to the same file on separate branches. Your colleague pushes their changes to the remote repository first and then you try to merge your changes into their branch. Git detects a conflict between your changes and your colleague's changes to the same file. You'll need to resolve the conflict by manually editing the file to combine both sets of changes or decide which changes to keep and which to discard. Once you've resolved the conflict, you can commit the changes and push them to the remote repository.

Answer

In Git, reverting a commit means undoing the changes made in that commit and creating a new commit with the inverse changes. This is useful when you want to undo a specific commit without deleting it entirely from the repository's history. 
Here are the steps to revert a commit in Git:
1. Identify the commit to revert: You can use the "git log" command to see a list of all the commits in your repository, and then identify the commit you want to revert.
2. Revert the commit: Use the "git revert" command followed by the commit hash of the commit you want to revert. For example, "git revert abcd1234" will create a new commit that undoes the changes made in the commit with the hash "abcd1234".
3. Commit the revert: Once you've reverted the commit, you'll need to commit the changes to the repository using the "git commit" command.
Now, let's talk about the difference between "git revert" and "git reset". 
The "git revert" command creates a new commit that undoes the changes made in a specific commit while preserving the original commit in the repository's history. This means that the original commit is still visible in the commit history, and you can see that it was later reverted.
On the other hand, the "git reset" command removes commits from the repository's history entirely. When you use "git reset", you're moving the branch pointer to a specific commit, which effectively deletes all the commits after that point. This can be useful if you want to undo a series of commits and start over from a specific point in time. However, it's important to note that this command can be dangerous if used incorrectly, as it can permanently delete commits from the repository's history.
In summary, "git revert" undoes changes made in a specific commit by creating a new commit, while "git reset" removes commits from the repository's history entirely.

Answer

In Git, a local repository is a copy of the repository on your local machine, while a remote repository is a copy of the repository hosted on a server or a cloud-based repository management service like GitHub, GitLab, or Bitbucket.
Here are some differences between local and remote repositories:
- A local repository is stored on your machine, while a remote repository is stored on a server or in the cloud.- A local repository is used to make changes to the code, while a remote repository is used to share changes with others.- You can only access a local repository from the machine it's stored on, while a remote repository can be accessed from any machine with internet access.
To push changes to a remote repository, you can follow these steps:
1. Add changes to the staging area: Use the "git add" command to add the changes you want to push to the staging area.
2. Commit changes: Use the "git commit" command to commit the changes to your local repository with a commit message that describes the changes you made.
3. Connect to the remote repository: Use the "git remote add" command to connect to the remote repository. For example, if the remote repository is on GitHub, you can use the command "git remote add origin https://github.com/your-username/your-repo.git". This adds a remote named "origin" to your local repository.
4. Push changes: Use the "git push" command to push your changes to the remote repository. For example, if you want to push changes to the "master" branch, you can use the command "git push origin master".
5. Authenticate if necessary: If you haven't authenticated with the remote repository, you may be prompted to enter your username and password or generate an SSH key.
Once you've pushed changes to the remote repository, others can see and access those changes by pulling the changes from the remote repository into their local repositories.

Answer

Sure, here's an example of a Git workflow for a team-based project:
1. Create the main branch:

git checkout -b main
git push -u origin main

2. Create a development branch to track changes:

git checkout -b development
git push -u origin development

3. Each developer creates a feature branch to work on a specific feature:

git checkout -b feature/feature-name

4. Work on the feature, commit changes to the feature branch:

git add .
git commit -m "commit message"

5. Push changes to the remote feature branch:

git push -u origin feature/feature-name

6. Once the feature is complete, create a pull request to merge the feature branch into the development branch:

git checkout development
git pull origin development
git merge --no-ff feature/feature-name
git push origin development

7. Review the pull request and approve it for merging into the development branch.
8. After all features are completed and merged into the development branch, create a release branch:

git checkout -b release/x.x.x

9. Test and fix any bugs on the release branch.
10. Merge the release branch into both the development and main branches:

git checkout development
git merge --no-ff release/x.x.x
git push origin development

git checkout main
git merge --no-ff release/x.x.x
git push origin main

11. Tag the main branch with the release version:

git tag -a x.x.x -m "Release x.x.x"
git push origin x.x.x

12. Delete the release branch:

git branch -d release/x.x.x

This workflow allows for parallel development of multiple features, while keeping the main and development branches stable and deployable. The use of pull requests allows for code review and collaboration between team members.

Answer

In Git, "git pull" and "git fetch" are two different commands that are used to update your local repository with changes from a remote repository.
"git pull" is used to fetch changes from the remote repository and merge them into your local branch in one step. It combines the "git fetch" command, which downloads the latest changes from the remote repository, with the "git merge" command, which merges those changes into your local branch.
"git fetch", on the other hand, only downloads the latest changes from the remote repository to your local repository. It does not automatically merge those changes into your local branch. Instead, it updates your local repository's copy of the remote repository's branch so that you can view the changes and choose to merge them manually later on.
Here are some scenarios when you might use each command:
Use "git pull" when:
- You want to update your local branch with the latest changes from the remote repository and merge them automatically.- You are the only person working on the branch, and you want to quickly incorporate changes made by others.
Use "git fetch" when:
- You want to download the latest changes from the remote repository to your local repository without automatically merging them into your local branch.- You want to preview the changes before merging them into your local branch.- You are working on a team and want to avoid merge conflicts by reviewing changes made by others before merging them.
Overall, "git pull" and "git fetch" are both important commands in Git that are used to keep your local repository up-to-date with changes made in a remote repository. However, it's important to understand the differences between them and use them appropriately based on your specific use case.

Answer

Git is a popular tool for collaborating with other developers on a project. Here's a high-level overview of how Git can be used for collaborative development:
1. Set up a remote repository: Create a remote repository on a Git hosting service like GitHub or Bitbucket. This is where all the changes made by collaborators will be stored.
2. Clone the repository: Each collaborator clones the remote repository to their local machine using the "git clone" command. This creates a local copy of the remote repository that the collaborator can work on.
3. Create and switch to a new branch: Each collaborator creates a new branch using the "git branch" command and switches to it using the "git checkout" command. This allows them to work on new features or make changes without affecting the main branch.
4. Make changes and commit them: Collaborators make changes to their local branch and commit them using the "git add" and "git commit" commands.
5. Push changes to the remote repository: Collaborators push their changes to the remote repository using the "git push" command. This updates the remote repository with their changes.
6. Review and merge changes: The project manager or another collaborator reviews the changes made by other collaborators and merges them into the main branch using the "git merge" command.
7. Handle merge conflicts: If there are merge conflicts between different branches, the project manager or another collaborator can use the "git mergetool" command to resolve the conflicts. This opens a merge tool that allows the user to manually select which changes to keep.
Here's an example of how merge conflicts can be handled in a collaborative setting:
1. Collaborator A creates a new branch and makes changes to a file.
2. Collaborator B creates a new branch and makes changes to the same file.
3. Collaborator A pushes their changes to the remote repository.
4. Collaborator B tries to push their changes to the remote repository but gets an error message saying there are conflicts.
5. Collaborator B pulls the latest changes from the remote repository using the "git pull" command.
6. Git detects a merge conflict because both Collaborator A and Collaborator B made changes to the same file.
7. Collaborator B uses the "git mergetool" command to resolve the merge conflict. This opens a merge tool that allows Collaborator B to manually select which changes to keep.
8. Collaborator B saves the changes and commits them using the "git add" and "git commit" commands.
9. Collaborator B pushes the changes to the remote repository using the "git push" command.
10. The changes made by Collaborator A and Collaborator B are now merged into the main branch of the project.
Overall, Git provides a powerful set of tools for collaborating with other developers on a project. By following best practices and using the appropriate commands, developers can work together to build high-quality software efficiently and effectively.

Answer preview

Yes, Git provides multiple ways to revert a commit. One way is to reset to a previous commit, and another way is to create a new commit that undoes the changes introduced by the original commit. Here are the steps for each approach: Resetting to a previous commit: 1. Find the commit hash of the commit you want to…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git rebase and Git merge are two different ways of combining changes from different branches in Git. Git merge creates a new commit that combines the changes from two or more branches. This is done by creating a new commit that has two or more parent commits, each of which contains the changes from one of the…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git bisect is a useful tool in Git that allows you to find the commit that introduced a bug by performing a binary search through the commit history. Here's how you can use Git bisect: 1. Identify a known good commit and a known bad commit. These are two commits in your Git history where you know that the bug was not…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git hooks are scripts that you can run automatically when certain Git events occur, such as before a commit is made, after a commit is made, or before a push is executed. They allow you to customize and automate your Git workflow by triggering custom actions in response to Git events. Here are a few examples of how…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git submodules are a feature in Git that allows you to include one Git repository as a subdirectory in another Git repository. This can be useful when you want to include code from another project in your own project, but want to keep the two codebases separate. Here's an example of how you might use Git submodules…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git cherry-pick and Git merge are both Git commands that are used to combine changes from one branch into another branch. However, they work in slightly different ways and are used in different situations. Git merge is used to combine changes from one branch into another branch. When you merge one branch into another…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

When multiple developers make changes to the same file or code block in a Git repository, it can lead to merge conflicts. A merge conflict happens when Git is unable to automatically resolve differences between the different versions of the code. To resolve a merge conflict in Git, follow these steps: 1. Pull the…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git reflog is a tool that maintains a log of all the changes to the Git repository, including commits, merges, and branch creations and deletions. The reflog records the SHA-1 hash of each commit, which serves as a unique identifier for that commit. One of the primary use cases for Git reflog is to recover lost…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git blame is a tool that allows you to track changes to a specific file by displaying the commit history of each line of code in the file. This can be useful for identifying who made a particular change to the code, when the change was made, and why it was made. To use Git blame, follow these steps: 1. Open a terminal…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

To configure Git to use a custom merge tool, you need to edit your Git configuration file. Here are the steps to follow: 1. Open your Git configuration file. You can find this file in your home directory (`~/.gitconfig`), or you can open it with the `git config --global --edit` command. 2. Add the following lines to…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Sure! Git pull is a command that fetches the latest changes from the remote repository and merges them into your local branch. By default, Git pull performs a merge, which creates a new merge commit to integrate the changes. On the other hand, Git pull --rebase fetches the latest changes from the remote repository and…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

To use Git log to view the history of a repository, simply navigate to the repository in your terminal and run the command `git log`. This will show you a chronological list of commits, starting with the most recent one. Git log has many options that you can use to filter the output and customize the information that…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git hooks are scripts that you can use to automate tasks and enforce policies in your Git workflow. Git supports various types of hooks, including pre-commit, pre-push, post-commit, and post-merge hooks, among others. To use Git hooks to enforce coding standards or run tests before committing code, you can create a…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git tags are useful for marking specific versions of a project, such as releases or milestones. Here are the steps to create and use Git tags: 1. Create a tag for the current commit: Replace tag-name with the name of your tag. 2. Push the tag to the remote repository: This will push the tag to the remote repository so…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git bisect is a powerful tool that can help you find the commit that introduced a bug in a Git repository. It works by performing a binary search on the commit history, checking out different commits one by one and allowing you to test whether the bug is present or not. In a complex project with multiple branches, you…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git hooks are scripts that are triggered by Git events such as committing or pushing code. These scripts can be used to automate various tasks such as running tests, checking for code style, or triggering builds. Here's an example of creating a Git hook that runs a script when code is committed: 1. Open your terminal…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git worktrees are a feature that allows you to work with multiple branches simultaneously by creating a separate working directory for each branch. This can be useful in situations where you need to work on multiple features or bugs at the same time, or when you need to work with multiple branches that have…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git submodules are useful when you need to include external dependencies in your Git repository, such as libraries or plugins, without having to manually copy them into your project directory. Here are the steps to use Git submodules: 1. Navigate to the root directory of your Git repository. 2. Initialize a submodule…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git subtree is a built-in Git command that allows you to manage a subdirectory of a repository as a separate project. The basic idea is that you can split off a subdirectory of a repository into its own repository, which can then be versioned, branched, and merged independently. To use Git subtree, you can follow…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git notes are a feature in Git that allow you to attach arbitrary metadata to a commit. Notes are not versioned like commits, but rather are attached to a commit using a SHA-1 hash. This means that notes can be added or removed from a commit without affecting the commit itself. To add a note to a commit, you can use…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git reflog and Git log are two Git commands that allow you to view the history of a Git repository, but they have different purposes. Git log is used to view the commit history of a repository, and can be used to see the changes that were made to the repository over time. By default, Git log displays the commit…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git rerere (Reuse Recorded Resolution) is a feature in Git that allows you to automatically reuse previously recorded resolutions for merge conflicts. This can be particularly useful when you have a complex codebase with multiple branches that are frequently merged together, resulting in the same conflicts occurring…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Both `git rebase --onto` and `git rebase -i` are advanced features in Git that allow you to selectively apply or modify commits in a branch. However, they serve different purposes and are used in different scenarios. `git rebase --onto` is used to move a series of commits from one branch to another. The syntax of `git…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git worktree is a feature that allows you to have multiple working directories for the same Git repository on the same machine. Each working directory has its own branch checked out and can be used independently of the others. It can also be used to work with multiple repositories simultaneously. To use Git worktree…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git submodules are a way to manage dependencies between Git repositories. It allows you to include one repository as a subdirectory within another repository, which can be useful for managing complex projects that consist of multiple smaller projects. To use Git submodules, you need to first add the submodule to your…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

To collaborate on an open-source project using Git, you can follow these steps: 1. Fork the project repository: To start contributing to an open-source project, you first need to create a copy of the project repository to your own account. This is known as forking the repository. You can do this by visiting the…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git sparse-checkout is a feature that allows you to clone only a portion of a repository, instead of cloning the entire repository. This can be useful in several scenarios, including: 1. Large repositories: If a repository is very large and you only need to work with a specific part of it, using sparse-checkout can…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

When you perform a Git rebase operation, there might be conflicts between the changes you're applying and the changes in the target branch. In such cases, Git will stop the rebase process and ask you to resolve the conflicts manually. After resolving the conflicts, you can use the `git add` command to stage the…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git notes can be a useful feature for tracking code reviews. When used in conjunction with a code review tool or process, Git notes can provide a way to associate comments, feedback, or approval status with specific commits or changesets in a repository. To use Git notes for code reviews, you can create a separate…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Yes, I can explain the difference between Git reset --hard and Git revert. Git reset --hard is a command used to completely discard any changes made to the working directory and revert to a previous commit. It not only resets the commit pointer to a previous commit but also discards any changes made to tracked files…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git subtree can be used to merge changes from a subdirectory of a repository into a separate project. The basic process involves adding the subdirectory as a remote repository, merging the changes, and then pushing the changes back to the original repository. Here are the steps: 1. Add the subdirectory as a remote…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

A common branching model that supports both feature development and hotfixes in Git is the Gitflow workflow. This workflow defines two main branches: master and develop. The master branch contains the stable, production-ready code, while the develop branch is where all feature development occurs. Here are the basic…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Git blame is a useful tool in Git for tracking changes to a file across multiple branches. It displays the author and the commit message for each line in a file, along with the SHA-1 hash of the commit that introduced the change. This information can be used to identify who made a particular change and when it was…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

Yes, I can explain the difference between Git merge-base and Git diff, and how to use them to find the changes introduced by a particular commit. Git merge-base is a command that finds the latest common ancestor between two branches. It returns the SHA-1 hash of the commit that is the most recent common ancestor of…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

Answer preview

When working on a feature branch in Git, it's common to have multiple commits that are related to each other. However, when you're ready to merge the feature branch into the main branch, it's often preferable to have a single commit that summarizes the changes made in the feature branch. This is where `git rebase…

Sign in to view this answer

Mid and senior level answers are included in every paid plan. Sign in to choose a plan, or browse the junior level answers for free.

More practice

Go further with Git

Git code challenges

10 challenges with answers

Behavioral Questions

10 questions with answers

Cultural Fit Questions

10 questions with answers

Competency-Based Questions

10 questions with answers

Motivational Questions

10 questions with answers

Communication Skills Questions

10 questions with answers

Scenario-Based Questions

10 questions with answers

Problem-Solving and Analytical Questions

10 questions with answers

Ethical and Integrity Questions

10 questions with answers

Industry-Specific Questions

10 questions with answers

Leadership and Management Questions

10 questions with answers

Personal Questions

10 questions with answers

About this topic

Git interview questions and answers

This page lists 45 Git interview questions with answers, ordered from junior to senior level. Commonly asked questions include "What is Git, and why do developers use it?", "Can you explain the difference between Git and GitHub?" and "Create a Git repository and initialize it with a README file, then add and commit a new file to the repository.".

Other frequently asked questions include "How do you handle merge conflicts in Git, and can you give an example of when you had to resolve one?", "How do you revert a commit in Git, and what is the difference between "git revert" and "git reset"?" and "Use Git to revert a commit, either by resetting to a previous commit or by creating a new commit that undoes the changes.". Review each answer and consider how you would adapt it to your own experience.

Practise Git in a mock interview

Answer questions one at a time and receive a score with written feedback on each answer.

Start a mock interview

Reviews and comments