Q1. What is Git?
Ans. Git is a distributed version control system that enables developers to track changes made to their code, collaborate with others on a project, and revert to previous versions if necessary. It is widely used in software development and has become an essential tool for many developers and development teams.
Q2. How Git works? Explain the architecture of Git.
Git is a version control system that functions by recording changes made to project files, storing those changes in a repository, and employing branches to enable the development of many project versions at once.
Each developer has a copy of the full repository on their own PC because Git's architecture is based on a distributed paradigm. They can now work on the project without being able to access to a main server thanks to this. Each developer has the ability to make modifications to their local copy of the repository, pull changes made by other developers, and then use Git to push those changes back to the main server.
Q3. Explain why Git is distributed?
Because each developer has a complete copy of the repository on their local system and can thus operate independently of a centralised server, Git is distributed.
This provides the following benefits:
Speed: Working with a local copy of the repository rather than a central server can be quicker for developers.
Offline Work: Developers are able to continue working on the project even when they are not connected to the network, and when they are, they can send their updates to the main server.
Resilience: Developers can work on their local versions of the repository even if the main server is down and push their changes to the server once it is back online.
Collaboration: By pushing and pulling changes between their local copies of the repository, developers can quickly exchange changes with one another.
Flexibility: In their local copy of the repository, developers can test out new features or bug fixes without having an impact on the project's main version.
Reduced Single Point of Failure: There isn't a single point of failure because every developer has a copy of the full repository. The repository can be rebuilt from the copies made by other developers even if the central server is lost or becomes inaccessible.
Q4. Explain Git workflow with image.
Q5. List top 10 Git commands.
Ans. Top 10 Git commands are:
git init: Initialise a new Git repository.
git add: Add changes to the staging area, preparing them to be committed.
git commit: Commit changes to the local repository.
git status: Check the status of the working directory and the staging area.
git log: View the commit history of the repository.
git branch: View and manage branches in the repository.
git checkout: Switch between branches or restore working tree files
git clone: Clone an existing repository from a remote location.
git merge: Merge changes from one branch into another.git diff: View the differences between the working directory, the staging area, and the last commit.