Debug School

Cover image for Git Assignment - 1
Salil Agrawal
Salil Agrawal

Posted on

Git Assignment - 1

Q1. What is Git?

  • GitHub makes it easy for developers to create and share code. Using free and open source software, your projects are hosted on the largest host of public projects – meaning other users can reach in and modify your code, or use it as a starting point for new development. Moreover, It provides reliable version control, collaboration, and deployment services that enable you to host your own projects with ease. And it's free!

Q2. How Git works? Explain the architecture of Git.

  • Git is a tool that helps developers keep track of changes made to their code. Developers can create a new "branch" to make changes without affecting the main code, and then "commit" the changes, which creates a snapshot of the code at that moment. They can also collaborate with other developers by working on a "remote" version of the code, which is hosted on a server and can be accessed by multiple people. Git allows developers to easily go back to earlier versions, and work together on the same codebase.

  • Git's architecture is based on a decentralised model which means that every developer has their own copy of the entire codebase and its history on their machine. Each change made is recorded as a "commit", which is a snapshot of the codebase. These commits are organised in a DAG (Directed Acyclic Graph) structure, which allows for easy navigation through different versions of the codebase. Git also uses "branches" as a way to separate different versions and "remote repositories" to collaborate with other developers.

Q3. Explain why Git is distributed?

  • Git is a distributed version control system because it allows every developer to have their own copy of the entire codebase and its history on their own machine. This means that every developer has a full copy of the codebase and all its history, so if the central server goes down, developers can still work on the code and commit their changes. Additionally, it allows for more flexibility and faster performance as developers can commit their changes locally and push them to the remote repository when ready. It also allows for offline work, and in case of any network issue, developers can still commit and push their changes when they regain connectivity.

Q4. Explain Git workflow with image.

  • Git workflow is a process that developers use to manage changes made to their codebase. The workflow starts with creating a new "branch" from the current version of the codebase. This allows developers to make changes without affecting the main code. Once the changes are done, developers can then "commit" the changes, which creates a snapshot of the code at that moment. Developers can then "push" the changes to a "remote" repository, which is a copy of the codebase hosted on a server that can be accessed by multiple people. Finally, the changes can be "merged" back into the main codebase with the help of pull requests.

Image description

Q5. List top 10 Git commands.

  1. git init - Initialises a new Git repository
  2. git clone - Creates a copy of a remote repository on your local machine
  3. git add - Adds changes to the staging area
  4. git commit - Creates a new commit with the changes in the staging area
  5. git status - Shows the status of the working directory and the staging area
  6. git diff - Shows the differences between the working directory and the last commit
  7. git log - Shows the commit history
  8. git branch - Lists all branches in the repository
  9. git checkout - Switches to a different branch or commit
  10. git merge - Merges changes from one branch into another

Top comments (0)