Day - 8 &9 DevOps challenge

Day - 8 &9 DevOps challenge

Basic Git & GitHub for DevOps Engineers

  1. ✔️ What is Git?

    Git is a version control system that helps track changes in files and projects, making it easier for multiple people to collaborate on the same codebase. It allows you to save different versions of your work, switch between them, and merge changes made by different contributors. Git is widely used in software development for its efficiency and ability to handle complex projects.

  2. ✔️What is GitHub?

    GitHub is a web-based platform that uses Git for version control. It provides a place for developers to store and collaborate on their code repositories. GitHub offers features like issue tracking, pull requests, and project management tools, making it easier for teams to work together and contribute to open-source projects. It also allows for easy sharing and discovery of code.

  3. ✔️What is Version Control?

    Version control is a system that manages changes to files over time. It helps track and organize different versions of a project, allowing you to revert back to previous states if needed. It enables collaboration among multiple developers by providing a central repository where changes can be shared and merged. Version control also helps in tracking who made specific changes, facilitating accountability and teamwork. It is an essential tool in software development for maintaining code quality and enabling efficient collaboration.

  4. ✔️How many types of version controls we have?

    1. Centralized Version Control Systems (CVCS): These systems have a central server that stores the entire history and files of a project. Developers can check out a copy of the project, make changes, and then commit them back to the central server.

    2. Distributed Version Control Systems (DVCS): In DVCS, every developer has a complete copy of the project's history and files on their local machine. This allows for more flexibility and offline work, as developers can commit changes locally and later synchronize them with others.

    3. Hybrid Version Control Systems: Some version control systems combine elements of both centralized and distributed systems. They provide a central repository but also allow developers to have their own local copies and work offline, merging changes with the central server when connected.

✔️Difference between Centralized and Distributed version control System.

Centralized VCSDistributed VCS
Has a central server that stores the repositoryEach developer has a complete copy of the repository
Requires network connectivity for most operationsRequires network connectivity for most operations
Developers check out files from the central serverDevelopers have their own local repository
Changes are committed directly to the central serverChanges can be committed locally and later synchronized
Limited branching and merging capabilitiesFlexible branching and merging, enabling parallel development
Relies on the central server for history and backupsEach developer's local repository serves as a backup
Examples: CVS, Subversion (SVN)Examples: Git, Mercurial
  1. ✔️Why we use distributed version control over centralized version control?

    Distributed version control offers several advantages over centralized version control:

    1. Offline Work: With DVCS, developers can work offline and commit changes to their local repository. This allows for uninterrupted productivity even when internet connectivity is unavailable.

    2. Flexibility and Independence: Each developer has their own complete copy of the repository, enabling them to experiment, create branches, and make changes independently without affecting others. This promotes flexibility and encourages parallel development.

    3. Faster Operations: DVCS operations like committing changes, branching, and merging are typically faster because they are performed locally without the need to communicate with a central server.

    4. Redundancy and Backups: Each developer's local repository acts as a backup, reducing the risk of data loss. In case of a central server failure, the distributed nature ensures that others still have access to the complete history.

    5. Collaboration and Forking: DVCS platforms like Git facilitate easy collaboration by allowing developers to clone and contribute to projects hosted by others. Forking, where developers create their own independent copies of a project, encourages innovation and experimentation.

    6. Decentralized Development: Distributed version control systems support distributed teams and decentralized workflows. Contributors can work on different aspects of a project independently and later merge their changes, making it easier to manage complex projects with multiple contributors spread across different locations.

      here an image to differentiate them:

      What Is a Version Control System & Do You Need One?

  1. ✔️Install Git on your computer :

    download git from git-scm.com/downloads and install it.

  2. ✔️Create an account on GitHub :

    1. Go to the GitHub website: Open your web browser and navigate to github.com.

    2. Sign Up: On the GitHub homepage, you'll find a "Sign Up" button. Click on it to start the registration process.

    3. Provide your information: Fill in the required information in the registration form, including your username, email address, and password. Choose a strong password to secure your account.

    4. Choose a plan: GitHub offers both free and paid plans. Select the plan that suits your needs. If you're just getting started, the free plan is usually sufficient.

    5. Complete the setup: After choosing a plan, you may be asked to provide additional information, such as your role or areas of interest. Fill in the requested details and proceed.

    6. Verify your email: GitHub will send you a verification email to the address you provided during registration. Open the email and click on the verification link to confirm your email address.

    7. Explore GitHub: Once your account is verified, you can start exploring GitHub's features, repositories, and communities. You can create your own repositories.

That's it! You have successfully created your GitHub account.

✔️You need to know some basic commands of git :

Command

Description

git init

Initializes a new Git repository in the current directory.

git clone

Creates a local copy of a remote repository.

git add

Adds changes or new files to the staging area for the next commit.

git commit

Records changes to the repository with a commit message.

git status

Shows the status of the working directory and staging area.

git push

uploads local commits to a remote repository.

git pull

Fetches and merges changes from a remote repository.

git branch

Lists, creates, or deletes branches in the repository.

git checkout

Switches to a different branch or restores files from a commit.

git merge

Combines changes from one branch into another branch.

git log

Displays a history of commits in the repository.

git remote

Manages remote repositories linked to the local repository.

  1. ✔️Create a new repository on GitHub and clone it to your local machine :

    step 1: Sign in to your GitHub account using your username and password.

    step 2: Once you are signed in, click on the "+" icon in the top-right corner of the GitHub homepage. From the dropdown menu, select "New repository."

    or, go to repositories and click on 'new' in the top right corner.

    or, click on green 'new' button

    step 3: Set up the repository: On the new repository creation page, you need to provide some information:

    Then click on 'create repository'

    you have successfully created a repository.

    step 4: After creating the Repository it will look something like this :

  2. ✔️Clone the repository to your local machine :

    step1: click on <>code, after that, we can see a path, and copy that path

    step 2: lets go into your local machine .

    step 3: git clone <paste_the_copied_link_here>

    it will clone your repository into your local

    step 4: type ls to confirm , see my 'mobile' repo is here

  3. ✔️Make some changes to a file in the repository and commit them to the repository using Git :

    step 1: Go to your cloned folder, in my case I use cd mobile

    step 2: let's check the git status using git status

    step 3: Now, stage it using the command git add . and check git status

    step 4: Now, commit the changes you using git commit -m " your message"

    step 5: push it to the repository using git push origin

    files are adeed sucessfully into the repository.

    Thank you so much for reading.

    Follow me on LinkedIn to see interesting posts like this : )

    linkedin.com/in/prabir-kumar-mahatha-6a0025..

    visit my git hub profile : https://github.com/PrabirKumarMahatha