Q1. What is Git?
Ans. Git is a version control system that allows developers to keep track of changes made to their code, collaborate with others on a project, and roll back to previous versions if needed.
Q2. How Git works? Explain the architecture of Git.
Ans. Git is a version control system that works by keeping track of changes made to files in a project, storing those changes in a repository, and using branches to allow for multiple versions of a project to be developed simultaneously.
The architecture of Git is based on a distributed model, which means that each developer has a copy of the entire repository on their local machine. This allows them to work on the project without needing to be connected to a central server. Each developer can make changes to their local copy of the repository and then use Git to push those changes back to the central server, or pull changes made by other developers.
Q3. Explain why Git is distributed?
Ans. Git is distributed because each developer has a full copy of the repository on their local machine, which allows them to work independently of a central server.
This has several advantages:
Speed: Developers can work on their local copies of the repository, which can be faster than working with a centralised server.
Offline Work: Developers can continue to work on the project even if they are not connected to the network, and then push their changes to the central server when they are back online.
Resilience: If the central server goes down, developers can continue to work on their local copies of the repository, and push their changes to the server once it is back up.
Collaboration: Developers can easily share changes with one another by pushing and pulling changes between their local copies of the repository.
Flexibility: Developers can experiment with new features or bug fixes in their local copies of the repository without affecting the main version of the project.
-
Reduced Single Point of Failure: Since each developer has a copy of the entire repository, there is no single point of failure. Even if the central server is lost or becomes unavailable, the repository can be recreated from the copies of other developers.
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 clone
: Clone an existing repository from a remote location. -
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 diff
: View the differences between the working directory, the staging area, and the last commit. -
git branch
: View and manage branches in the repository. -
git checkout
: Switch between branches or restore working tree files. -
git merge
: Merge changes from one branch into another.
Top comments (0)