Q1. What is Git?
GIT is a version control system. It records the changes made to our code in its repository. We can see the history of the changes made, and can see who has made changes, when and why the changes were made. With GIT we can easily revert back to previous version of code, if the new version does not work properly.
Q2. How Git works? Explain the architecture of Git.
GIT records the changes made to a project file and stores these changes to a local repository and a remote repository. Developer can pull changes from other developers and make changes in local as well as remote repository.
By using the command "git add", a change in working directory is added to staging area. The "git commit" command then captures the state of changes in the staging area and saves this snapshot in the local repository. "git push" command is then used to upload local repository content to a remote repository.
GIT falls in decentralized category, where every developer has a copy of the project with its history on their machines.
Q3. Explain why Git is distributed?
GIT is distributed because each developer has a copy of the project with its history on their local machines. If the central server is offline, developers can synchronize their work directly.
Q4. Explain Git workflow with image.
The changes made to a project file in working directory are first added to staging area by using the command "git add". files in staging area are marked to be committed, but not yet committed.
When we execute the command "git commit", all the files that are staged, their changes will be committed to the local repository. At this point all the changes are safely stored on the local repository.
Now we have to push the files from local repository to remote repository. To do this we use "git push" command. This command pushes all the changes in local repository to remote repository.
Q5. List top 10 Git commands.