Our Blog:

Mastering the Most Common Git Technical Questions

Andrej Vajagic

Andrej Vajagic

16.12.2023, 15:20

Read time: undefined mins

Mastering the Most Common Git Technical Questions

Elevate your interview prep with our focused guide, "Mastering the Most Common Git Technical Questions." Tailored for senior frontend roles, this blog distills the top 20 Git interview questions and answers, offering concise, insightful explanations. Whether a seasoned coder or an aspiring developer, our resource sharpens your Git expertise, ensuring you're interview-ready. Unlock the power of Git knowledge and stand out in your next technical interview!

1. What is the purpose of Git in frontend development?

Answer: Git is crucial for version control, managing code changes, collaborating with other developers, and maintaining a historical record of the project's progression.

2. How does Git differ from other version control systems?

Answer: Git is a distributed version control system, meaning every developer's working copy is a full-fledged repository with complete history and version tracking capabilities, unlike centralized systems.

3. Can you explain branching in Git?

Answer: Branching in Git is the process of diverging from the main line of development and continues to do work without affecting that main line.

4. How do you merge branches in Git?

Answer: To merge branches, you use the git merge command. This command combines the changes from one branch into another, usually the main branch.

5. What is a 'conflict' in Git, and how do you resolve it?

Answer: A conflict occurs when Git cannot automatically resolve differences in code between merged commits. Conflicts are resolved by manually editing the conflicted files, and then committing the resolved changes.

6. Explain the difference between git pull and git fetch.

Answer: git fetch only downloads new data from a remote repository, but it doesn't integrate any of this new data into your working files. git pull does both—it fetches and then merges.

7. How do you revert a commit in Git?

Answer: To revert a commit, use git revert [commit-hash]. This creates a new commit that undoes the changes made in the given commit.

8. What is a 'rebase' in Git?

Answer: Rebasing is the process of moving or combining a sequence of commits to a new base commit. It's a cleaner alternative to merging, as it creates a linear project history.

9. How would you resolve merge conflicts in a Git repository?

Answer: To resolve merge conflicts, you need to manually edit the files shown by Git, remove the conflicts, and then mark them as resolved using git add. After that, you can continue the rebase or merge process.

10. What are the best practices for using Git in a team environment?

Answer: Best practices include committing small, incremental changes, writing meaningful commit messages, using branches for features, bug fixes, and experimentation, and regularly syncing with the main branch.

11. How do you handle a situation where your feature branch is behind the main branch?

Answer: To update a feature branch, you would either merge the main branch into your feature branch or rebase your feature branch onto main.

12. What is a gitignore file and how do you use it?

Answer: A .gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; it's typically used for log files, temporary files, and build artifacts.

13. Explain the purpose of a pull request.

Answer: A pull request is used in team environments to notify team members that changes in a branch are ready for review, or to start a discussion about the changes before integrating them into the main branch.

14. How do you squash commits in Git and why would you do it?

Answer: Squashing in Git combines multiple commit messages into one. It's useful for keeping the commit history clean and understandable. This is done using git rebase -i.

15. What is the difference between HEAD, working tree and index, in Git?

Answer: The HEAD is a reference to the last commit in the current checked-out branch, the working tree holds the actual files, and the index serves as a staging area for commits.

16. How do you find out the author and committer of a particular commit in Git?

Answer: You can use git show [commit-hash] to display the commit's metadata, including the author and committer.

17. Explain how you would create a new repository in Git.

Answer: To create a new repository, use git init, which initializes a new Git repository and begins tracking an existing directory.

18. What is git stash and when would you use it?

Answer: git stash temporarily shelves changes you've made to your working copy so you can work on something else, and then come back and re-apply them later on.

19. How do you manage different configurations for different environments in your frontend projects using Git?

Answer: This can be managed by using environment-specific branches, or external configuration files that are not tracked by Git, or using Git's config command for repository-specific settings.

20. What strategies do you use for branching and merging in a project with a large team?

Answer: Strategies include feature branching, Gitflow workflow, or the Forking workflow, all of which help manage changes in a large team by isolating work in branches, and carefully managing integration with the main branch.


Accelerating Digital Success. Experience the future of web development – faster, smarter, better. Lets innovate together.

©2024 Dreit Technologies | All rights reserved


  • +38 64 577 3034
  • Serbia
  • Marka Pericina Kamenjara 11A, Ruma
  • Contact us