GIT 10 Interview Questions

Опубликовано: 28 Сентябрь 2024
на канале: Tech Interview Questions
31
2

What is GIT, and why is it used in software development?

Answer: GIT is a distributed version control system used in software development to track changes to source code. It helps developers collaborate, maintain a history of changes, and manage multiple versions of a project.

What is the difference between GIT and other version control systems like SVN?

Answer: GIT is distributed, meaning each developer has a complete repository. SVN is centralized, where developers check out code from a central repository. GIT offers better branching and merging capabilities.

Explain the basic GIT workflow.

Answer: The basic GIT workflow involves three main stages: working directory, staging area, and repository. Developers make changes in the working directory, stage those changes with git add, and then commit them to the repository with git commit.

What is a GIT branch, and why would you use multiple branches in a project?

Answer: A GIT branch is a separate line of development within a repository. Multiple branches are used to work on features, bug fixes, or experiments without affecting the main codebase. They can be merged when ready.

What is a GIT merge conflict, and how can it be resolved?

Answer: A merge conflict occurs when GIT cannot automatically merge changes from different branches. To resolve it, developers need to manually edit the conflicting files, choose which changes to keep, and then commit the resolved files.

Explain the difference between GIT pull and GIT fetch.

Answer: git pull fetches changes from a remote repository and merges them into the current branch. git fetch only retrieves changes from the remote repository but does not automatically merge them. Developers can inspect the changes before merging.

What is GIT rebase, and when might you use it?

Answer: GIT rebase is a command used to rewrite the commit history. It can be used to combine, reorder, or squash commits. Developers often use rebase to keep a cleaner, linear commit history before merging branches.

What is a GIT tag, and why are they useful?

Answer: A GIT tag is a reference to a specific commit in the repository's history. Tags are useful for marking important milestones or versions of a project. They provide a stable reference point for releases.

Explain GIT's distributed nature and how it differs from centralized version control systems.

Answer: In GIT, each developer has a complete copy of the repository, including its entire history. This allows for offline work and decentralized collaboration. Centralized systems like SVN rely on a central server for version history.

What is GIT's "HEAD" in relation to branches and commits?

Answer: GIT's "HEAD" is a special pointer that refers to the currently checked-out branch or commit. It represents the most recent state of the working directory and allows developers to navigate and make changes within the repository.

What is a GIT remote, and why is it important in collaborative development?

Answer: A GIT remote is a reference to a repository hosted on a remote server. It's essential in collaborative development because it allows multiple developers to share and synchronize changes to a common codebase.

Explain the difference between GIT push and GIT pull.

Answer: git push is used to send local commits to a remote repository, while git pull is used to fetch changes from a remote repository and merge them into the current branch.

What is GIT branching strategy, and why is it important in software development projects?

Answer: GIT branching strategy defines how branches are organized and used in a project. It's important because it helps manage parallel development, isolate features, and ensure a structured and manageable codebase.

What are GIT hooks, and how can they be used in the development workflow?

Answer: GIT hooks are scripts or programs that can be executed before or after specific GIT events. They are used to automate tasks such as code validation, testing, and deployment in the development workflow.

What is GIT cherry-picking, and when might you use this feature?

Answer: GIT cherry-picking is the process of selecting specific commits from one branch and applying them to another branch. It is often used to selectively bring in changes or bug fixes from one branch to another.

Explain the concept of GIT submodules and when they are useful.

Answer: GIT submodules allow you to include another GIT repository within your own. They are useful when you need to include external dependencies or libraries as part of your project while keeping them in separate repositories.

What is GIT bisect, and how can it help in debugging code?

Answer: GIT bisect is a binary search tool used to pinpoint the exact commit where a bug or regression was introduced. It automates the process of identifying the problematic commit by systematically testing revisions.