Day 8 - 90 DaysOfDevOps - Basics of Git & GitHub

Day 8 - 90 DaysOfDevOps - Basics of Git & GitHub

ยท

9 min read

๐Ÿ”ด What is Git?

Git is a distributed version control system (VCS) that helps developers track changes in their source code and collaborate with others on software projects.

It was created by Linus Torvalds in 2005 to manage the development of the Linux kernel, but it has since become one of the most widely used version control systems for all types of software development.

๐Ÿ”ดKey Features of Git:-

  1. Version Control: Git allows developers to keep track of changes to their code over time. It records every modification made to the files in a repository, which allows developers to revert to previous versions, compare changes, and understand the history of the project.

  2. Distributed System: Git is a distributed version control system, meaning that every developer working on a project has a complete copy of the entire repository, including its history, on their local machine. This allows developers to work offline and independently, yet still collaborate effectively.

  3. Repository: A Git repository is a collection of files and directories managed by Git. It contains the entire history of the project, as well as branches, tags, and other metadata.

  4. Commits: A commit represents a snapshot of the changes made to the code at a specific point in time. Each commit has a unique identifier, and it includes information such as the author, the commit message, and the changes made.

  5. Branches: Git allows developers to create separate branches from the main codebase, called the "master" or "main" branch. Branches are used to work on new features, bug fixes, or experiments without affecting the main codebase. Once the changes in a branch are tested and reviewed, they can be merged back into the main branch.

๐Ÿ”ด What is Github?

GitHub is a web-based platform and hosting service that provides version control functionality using Git. It allows developers to collaborate on software projects, track changes, manage code repositories, and work together on code development. GitHub was launched in 2008 and quickly became one of the most popular and widely used code collaboration platforms in the world.

๐Ÿ”ด Key features of GitHub:-

  1. Git Repository Hosting: GitHub provides a hosting service for Git repositories. Developers can create repositories to store their code and its entire history. These repositories can be either public, allowing anyone to view and contribute, or private, accessible only to selected collaborators.

  2. Collaboration and Social Networking: GitHub fosters collaboration and social interaction among developers. It allows developers to follow other users, "star" repositories to show appreciation, and contribute to open-source projects. The platform encourages community involvement and knowledge sharing.

  3. Pull Requests and Code Review: When developers want to propose changes to a project hosted on GitHub, they create a pull request. This allows others to review the proposed changes, discuss them, and suggest modifications before merging the code into the main repository. Pull requests are fundamental to open-source projects and collaborative development.

  4. Issue Tracking: GitHub includes an issue tracking system that allows developers to report bugs, suggest enhancements, or discuss various aspects of the project. Issues can be labeled, assigned, and linked to specific commits or pull requests, making it easier to manage the development process.

๐Ÿ”ด What is Version Control?

Version Control, also known as Revision Control or Source Control, is a system that enables developers to manage changes to their software code and other digital assets over time. It provides a structured way to track, organize, and maintain different versions of files, allowing developers to collaborate efficiently, roll back changes, and maintain a history of project modifications. The primary purpose of version control is to address challenges related to collaboration, code management, and project stability in software development and other file-based workflows.

๐Ÿ”ด Key features of Version Control:-

  1. Track Changes: Version control systems (VCS) record every change made to the files in a project, capturing the differences between each version. This allows developers to see what changes were made, who made them, and when they were made.

  2. Revert to Previous Versions: If a mistake is made or a feature needs to be rolled back, version control allows developers to revert to an earlier version of the project. This capability ensures that the project can always be restored to a known and stable state.

  3. Collaborate and Coordinate: Version control systems are often used in team-based environments. Multiple developers can work on the same project simultaneously, and the version control system manages the merging of their changes. This makes it easier to collaborate on code and avoids conflicts.

  4. Branching and Merging: Version control systems support branching, which allows developers to create separate lines of development. Branches can be used to work on new features or bug fixes without affecting the main codebase. Once the changes are ready, they can be merged back into the main branch.

  5. Code Review: With version control, developers can propose changes to the codebase in a controlled manner. Code review tools are often integrated into version control platforms, allowing team members to review proposed changes before they are merged.

๐Ÿ”ด How many types of version controls do we have?

There are primarily two main types of version control systems:

  1. Centralized Version Control (CVCS): In CVCS, there is a central server that hosts the repository. Multiple developers connect to this central server to check out files and make changes. All changes are committed back to the central server. This model requires a constant network connection to access the central repository. Examples of CVCS include Apache Subversion (SVN) and Perforce.

  2. Distributed Version Control (DVCS): In DVCS, each developer has a complete copy of the entire repository, including its history, on their local machine. This allows developers to work independently and efficiently, without requiring a constant connection to a central server. Changes can be committed locally and later synchronized with other repositories. DVCS provides better support for offline work and improved collaboration among developers. Git, Mercurial, and Bazaar are popular examples of DVCS.

    Both CVCS and DVCS serve the purpose of version control and keeping track of changes in software projects. However, DVCS has become more popular due to its distributed nature, allowing for easier collaboration among developers, efficient branching and merging, and the ability to work offline. Git, being a distributed version control system, has gained significant adoption and is now the most widely used version control system in the software development industry.

๐Ÿ”ด Why do we use distributed version control over centralized version control?

Distributed Version Control Systems (DVCS) like Git offer several advantages over Centralized Version Control Systems (CVCS) like Subversion (SVN) or Perforce.

๐Ÿ”ด Some of the Advantages of DVCS over CVCS are as follows:-

  1. Offline Work: One of the most significant advantages of DVCS is that developers can work offline without requiring a constant connection to a central server. Each developer has a complete copy of the entire repository on their local machine, which allows them to work independently, commit changes, create branches, and perform other version control operations without an internet connection.

  2. Faster Operations: DVCS typically performs operations faster than CVCS. Since all the version control operations are done locally on the developer's machine, actions like commits, viewing history, creating branches, and switching between branches are faster because they don't require communication with a remote server.

  3. Better Collaboration: DVCS facilitates easier and more flexible collaboration among developers. With CVCS, developers often have to wait for others to check in their changes to the central repository before they can start working on the latest version. In contrast, DVCS allows developers to create branches and work on their features independently. Collaboration becomes smoother, as merging and sharing changes is more efficient.

  4. Branching and Merging: DVCS excels in managing branches and merging changes. Branching in DVCS is lightweight and easy, encouraging developers to create feature branches, experiment, and work on multiple tasks simultaneously without affecting the main branch. Merging branches in DVCS is typically less error-prone due to its distributed nature, as developers can resolve conflicts locally before pushing the changes back to the central repository.

  5. Redundancy and Reliability: In DVCS, every developer has a complete copy of the entire repository. This redundancy provides an additional layer of data protection. Even if a central server goes down, each developer's local copy can be used to restore the repository or switch to another server.

  6. Flexibility in Workflows: DVCS allows teams to adopt various workflows based on their needs. Developers can follow centralized workflows if they prefer, where a designated branch acts as the main integration point. They can also use more complex workflows like Gitflow, where multiple long-lived branches are used for different stages of development.

  7. Open Source and Community: Git, being the most popular DVCS, has a vast and active open-source community. Numerous tools, integrations, and services are built around Git, making it easier to integrate with other development tools and services.

Task 1: Install Git on your Computer

Step 1:- Go to the official website and Download the Latest Version of Git.

Step 2:- Double click on the downloaded file and start Installation.

Step 3:- Follow the Installer's instruction. generally, you can leave the Default setting as they are, but you can customize them if you want.

Step 4:- while Installation, you will be prompted to the component setting you can keep as mentioned. and click next

Step 5:- Complete the Installation process by pressing Finish button.

Step 6:- Once Git is installed, open the command prompt and check the version of Git. whether it is correctly installed or not.

Task 2:- Create a free account on GitHub

To create a GitHub account please follow the below steps:-

  1. Open GitHub Website: Open your web browser and go to the GitHub website at github.com.

  2. Sign Up: On the GitHub homepage, you'll see a "Sign Up" button at the top right corner of the page. Click on it to start the account creation process.

  3. Enter Your Information: GitHub will ask you to provide some basic information to set up your account. You need to provide the following details:

    • Username: Choose a unique username for your GitHub account. This will be your identity on GitHub and will be used in your profile URL (e.g., github.com/your-username).

    • Email Address: Enter a valid email address. This will be used for communication-related to your GitHub account.

    • Password: Create a strong and secure password to protect your GitHub account.

  4. Complete CAPTCHA: To verify that you are a human user, GitHub may ask you to complete a CAPTCHA or other security measures.

  5. Select Your Interests: GitHub may prompt you to select your interests or types of projects you're interested in. This step is optional, and you can skip it if you prefer.

  6. Verify Your Email: After completing the sign-up process, GitHub will send a verification email to the email address you provided. Check your email and click on the verification link to confirm your account.

    You are now ready to use GitHub.

ย