DevOps, Day -  8 & 9

DevOps, Day - 8 & 9

Basic Git & GitHub for DevOps Engineers.

  1. What is Git?

    What is Git? | How It Work | Scope & Skill | Career Growth And Advantage

    Git is like a digital filing cabinet for code. It helps keep track of changes made to files and allows multiple people to work on the same project without getting in each other's way. It also allows you to go back in time to previous versions of the code if something goes wrong. Think of it like a time machine for your code.

  2. What is GitHub?

    What Is GitHub, and What Is It Used For?

    • GitHub is a web-based platform that uses Git as its underlying version control system.

    • It provides a user-friendly interface for managing and collaborating on Git repositories, allowing developers to easily host and share their code with others.

    • With GitHub, developers can contribute to open-source projects, review code changes made by others, and track issues and bugs in their projects.

    • In addition, GitHub offers various tools and integrations to support the development process, such as continuous integration and deployment, project management, and team communication.

  3. What is version control?

    Centralized vs Distributed Version Control System

    • Version control refers to the ability to track changes made to code over time.

    • Git creates snapshots of code at different points in its development, allowing developers to compare or revert changes.

    • Git uses branches to enable multiple people to work on the same codebase without interfering with each other's work.

    • Git makes it easy to merge changes back into a shared codebase.

    • Version control in Git allows developers to work collaboratively and efficiently while keeping track of changes and ensuring that the code remains organized and manageable.

  4. What are the different types of version control?

    • Centralized: All code is stored in one central location and developers make changes to it from their own computers. Changes are merged back into the central location to create a final version.

      Version Control | Interactive Media Design

    • Distributed: Each developer has their own copy of the code on their computer, and they can make changes to it independently. Changes are merged together when they're ready, and there is no central location that holds the "official" version of the code.

      What Is Git | Explore A Distributed Version Control Tool | Edureka

  5. Difference between Centralized and Distributed VCS.

    Version Control | Centralized vs Distributed System - YouTube

  6. Why do we use Distributed version control over Centralized version control

  • Decentralization:

    Each developer has a full copy of the repository on their local machine.

    This allows developers to work offline and makes DVCS more resilient to network failures.

  • Branching and merging:

    DVCS tools make it easy to create and manage branches locally.
    This allows developers to experiment with new features without affecting the main codebase.

  • Collaboration:

    DVCS tools provide features for sharing code changes, reviewing and commenting on each other's work, and tracking changes made by each team member.
    This enables developers to work independently and collaborate more effectively.

  • Flexibility:

    Each developer has their own copy of the repository, which means they can choose how they want to work and which branches to work on.

    This allows developers to work independently and with more autonomy.

  • Speed:

    DVCS tools are usually faster than centralized systems because they work with local repositories.

    This makes operations like committing changes and switching between branches faster and more efficient.


Task:

  1. Install Git on your computer.
    You can download it from the official website at https://git-scm.com/downloads

  2. Create a free account on GitHub.
    Go to the GitHub website: github.com

    • Click the "Sign up" button in the top right corner of the page.

    • On the "Create your account" page, enter your username, email address, and a strong password.

    • Complete the security verification step by solving the puzzle or answering the question.

    • Click the "Create account" button to create your account.

    • Check your email for a verification message from GitHub, and follow the instructions to verify your email address.

    • Once your email address is verified, you can start using GitHub!
      Later, you can sign up at https://github.com/ whenever you want, after creating your account.

  3. GIT commands.
    Here are some commonly used GitHub commands:


Exercises:

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

    step 1: Goto your Github account, and click on Repositories, beside you can see the New button.

    step 2: After clicking New, you can see something like the below image. And also check [βœ”οΈ] README file. And create a Repository.

    step 3: Clone it to your local
    After creating the Repo, we can see something like this

    Now, click on <>code, after that, we can see a path, and copy that path.
    step 4: Now go to your local,
    In my case, I created a DevOps Repo remotely and devtask folder locally.
    Now type the command git clone paste_the_copied_link
    it will clone everything present in remote Repo to your local. After ls Now we can see Devops (remote repo) in local.

  2. Make some changes to a file in the repository and commit them to the repository using Git

    step 5: Now change the directory to DevOps as cd Devops
    I created 90 subdirectories in it.

    And added content in a few directories.

    step 6: Now, check the git status

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

    step 8: Now, commit the changes you have done using the below command.
    here, -m is used to add some message within the double quotes (" ").

    Push the changes back to the repository on GitHub.

    step 9: Now, we have committed the changes, but it is not displayed in your remote Repo. Hence to see these contents in the remote repo, we need to push using the below command.

    step 10: Now go and check in your remote repo, we can see all the changes done locally, at our remote repo as shown below.

  3. Create a new branch

    step 1: command used is git checkout -b branch_name
    After executing this command, you will be switched to your new branch.
    step 2: Here, I created a dev_branch directory which includes 2 files and contents within it.[day10_file.txt was created in the main branch, as it was not committed and pushed, it is displayed here too]
    step 3: check git status
    step 4: Now type ls -a which shows all the files created in the new branch.
    step 5: Now add it to git by using the command git add .
    step 6: Now commit it by using the command git commit -m "your message"

    step 7: After committing we will be left over with 1 final step, i.e, pushing it into
    git, by using the command git push origin branch_name

    After performing all these steps, you can see something like thisπŸ‘‡

    Now you can visit your remote and see the changes you did, in my case, I gotπŸ‘‡

    After selecting the newly created branch i.e, devops_branch click on compare and pull request --> Create pull request --> Merge pull request --> Confirm merge.

    After you select your new branch, the files which u created inside it, will be displayed asπŸ‘†
    step 8: If you want to switch back to your main, just type git checkout master/main in your terminal.

Thank you so much for reading.

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

Linkedin

Β