Day 08/90 Basic Git & GitHub for DevOps Engineers.

Day 08/90 Basic Git & GitHub for DevOps Engineers.

In this blog post, We learn about the Git and GitHub.


What is Git?

Git is a distributed version control system (DVCS) that allows developers to track changes in their codebase efficiently. It was created by Linus Torvalds in 2005 to manage the development of the Linux kernel. Here's a breakdown of what Git is and how it works:

  1. Version Control System: Git helps developers manage changes to their codebase over time. It allows users to track modifications, revert to previous versions, and collaborate with others seamlessly.
  2. Distributed: Unlike centralized version control systems, where the codebase is stored on a central server, Git is distributed. Each developer has a local copy of the entire repository, including its history. This decentralization enables offline work and faster access to the repository.
  3. Snapshots: Git records changes to files in the form of snapshots or commits. Each commit represents a snapshot of the entire project at a specific point in time. Developers can create new commits to save their work as they make changes to the code.
  4. Branching: Git allows developers to create branches, which are independent lines of development. Branches enable developers to work on new features or fixes without affecting the main codebase. Once the changes are complete, they can be merged back into the main branch.
  5. Merge and Conflict Resolution: When merging changes from one branch to another, Git automatically combines the modifications. In cases where there are conflicting changes (i.e., changes made to the same line of code), Git prompts users to resolve the conflicts manually.
  6. Remote Repositories: Git supports remote repositories, which are copies of the project hosted on servers accessible over the internet. Developers can push their local changes to a remote repository or pull changes from it to synchronize their work with collaborators.
  7. Open Source and Community: Git is open-source software, meaning its source code is freely available for anyone to view, modify, and distribute. It has a large and active community of developers who contribute to its development and provide support through forums, documentation, and tutorials.


What is Github?

GitHub is a web-based platform and service that provides hosting for software development projects using the Git version control system. It serves as a collaborative platform for developers to work on projects, share code, and collaborate with others. Here's what GitHub offers:

  1. Repository Hosting: GitHub allows users to create repositories (repos) to store their project code. Each repository can contain files, directories, images, and other resources related to the project.
  2. Version Control: GitHub uses Git, a distributed version control system, to track changes to files within repositories. Developers can create branches, make changes, and merge them back into the main codebase, all while preserving the project's history.
  3. Collaboration Tools: GitHub provides a range of collaboration features, including pull requests, issues, and project boards. These tools enable developers to discuss changes, review code, track bugs, and manage project tasks effectively.
  4. Community and Social Features: GitHub fosters a vibrant community of developers from around the world. Users can follow other developers, star repositories, and contribute to open-source projects. This social aspect encourages knowledge sharing and collaboration among developers.
  5. Documentation and Wikis: GitHub allows developers to create and maintain project documentation using wikis. This feature helps teams document project guidelines, procedures, and other essential information.
  6. Integration and Extensibility: GitHub integrates with various third-party services and tools, such as continuous integration (CI) platforms, code quality analyzers, and project management tools. This integration enhances workflow automation and project management capabilities.


What is Version Control? How many types of version controls we have?

Version control, also known as revision control or source control, is a system that manages changes to files, documents, or any other set of information over time. It allows users to track modifications, revert to previous versions, and collaborate with others effectively. Version control is particularly valuable in software development, where multiple developers work on the same codebase concurrently.

There are primarily two types of version control systems:

  1. Centralized Version Control Systems (CVCS):

  • In a CVCS, there is a single, centralized repository that stores the entire history of the project.
  • Developers check out files from the central repository to work on them locally. Once they make changes, they commit those changes back to the central repository.
  • Examples of CVCS include Concurrent Versions System (CVS) and Subversion (SVN).

  1. Distributed Version Control Systems (DVCS):

  • In a DVCS, each developer has their own local repository, containing the complete history of the project.
  • Developers can work offline, as they have access to the entire repository history locally.
  • Changes are synchronized between repositories by pushing and pulling changesets between them.
  • Examples of DVCS include Git, Mercurial, and Bazaar.

While CVCS and DVCS serve the same purpose of managing changes to codebases, DVCS offers several advantages over CVCS, such as better support for distributed development, improved performance, and increased flexibility.


Why we use distributed version control over centralized version control?

There are several reasons why distributed version control systems (DVCS) like Git are preferred over centralized version control systems (CVCS) like SVN or CVS:

  1. Offline Work: With DVCS, developers have a complete copy of the repository, including its entire history, on their local machines. This means they can work offline without needing constant access to a central server. Developers can commit changes, create branches, and perform other version control operations locally, and then synchronize their work with the central repository when they're back online.
  2. Faster Performance: DVCS typically offers faster performance compared to CVCS. Since most operations are performed locally, such as committing changes or switching branches, they tend to be quicker because they don't require network communication with a central server.
  3. Better Support for Branching and Merging: DVCS systems like Git excel at branching and merging workflows. Developers can create branches for new features or bug fixes, work on them independently, and merge them back into the main codebase seamlessly. DVCS makes branching and merging workflows more manageable and less error-prone compared to CVCS.
  4. Increased Flexibility: DVCS provides greater flexibility in how developers collaborate and manage their projects. Each developer has their own repository, allowing them to experiment, make changes, and work at their own pace without impacting others. This flexibility fosters creativity and innovation within development teams.
  5. Enhanced Security: DVCS offers enhanced security features compared to CVCS. Since each developer has a complete copy of the repository, the risk of data loss due to a central server failure is mitigated. Additionally, DVCS provides mechanisms for verifying the integrity of commits and protecting against unauthorized changes.
  6. Decentralized Development: DVCS encourages decentralized development models, where contributors from around the world can work on the same project without being dependent on a central authority. This decentralization fosters collaboration, empowers contributors, and promotes a more inclusive development process.Overall, the advantages of distributed version control, including offline work, faster performance, better support for branching and merging, increased flexibility, enhanced security, and decentralized development, make DVCS like Git the preferred choice for many software development teams and projects.


Task 1: Install Git

To get started, we’ll install Git on your computer. Git works on Windows, macOS, and Linux. Follow these simple steps:

  1. Go to git-scm.com/downloads, the official Git website.
  2. Download the installer that matches your operating system.
  3. Run the installer and follow the on-screen instructions to finish the installation.
  4. Once the installation is done, open a terminal or command prompt, and type git — version to make sure Git is installed correctly. You should see the version number displayed.

sudo apt-get update && sudo apt-get install git 
git --version        


Task 2: Create a GitHub Account

GitHub is a popular platform where people store their Git projects and work together on them. If you don’t have a GitHub account yet, here’s how you can create one:

  1. Open your web browser and go to github.com.
  2. On the GitHub homepage, click on the “Sign up” button.
  3. Fill in the required information, like your username, email, and password.
  4. Choose a plan that suits you (Free or one of the paid options) based on your needs.
  5. Complete the verification process, which might include solving a CAPTCHA or confirming your email.

Once you finish these steps, congratulations! You’ve successfully made your GitHub account. Now, you can start sharing and collaborating on your projects.


Task 3: Create a new repository on GitHub

Let’s get started by creating a new repository on GitHub, where we’ll keep and organize our code. Follow these simple steps:

  • Open your web browser and visit github.com.
  • Log in to your GitHub account.
  • On the GitHub homepage, click the “+” button at the top-right corner, then select “New repository” from the menu.


  • Give your repository a meaningful name.
  • You can also add a description to give more details about your repository.
  • Choose whether you want the repository to be public or private, depending on your needs.

  • Finally, click the “Create repository” button to create your new repository. That’s it! Your central code storage is ready to go.


Task 4: Clone the Repository to Your Local Machine

Our repository is created on GitHub. You can now use the “git clone” command to duplicate the central repository onto your local machine’s repository. Here’s how you can do it in simple steps:

  1. Go to your repository page on GitHub and click on the “Code” button.
  2. Copy the repository URL.
  3. Open the terminal or command prompt on your computer.
  4. Navigate to the directory where you want to save the repository.
  5. Use the command “git clone” followed by the repository URL you copied. For example git clone github.com/your-username/your-repository.git
  6. Press Enter, and the repository will be cloned to your local machine.

Great job!.... You have successfully cloned the repository to your local machine. Let’s proceed to the next exercise.


Task 4: Make Changes, Commit, and Push

Now that you have the repository copied to your computer, you can make changes to the files and keep track of those changes. Follow these simple steps:

  1. Move to the repository directory.

2. Create two files using the touch command.

3. Use the command “git status” to see the changes you made. It will show the modified files.

4. Use the command “git add” followed by the file names to prepare the tracking changes. For example: “git add filename.txt” or “git add .” to track all changes. Now check the status and our file is now tracked.

5. Use the command “git commit” to save the changes with a meaningful message describing the modifications. For example git commit -m ‘add two files’

6. Finally, use the command “git push” to upload the committed changes back to the repository on GitHub. For example: “git push origin main” or “git push origin master,” depending on the branch name.

By following these steps, you’ll successfully make changes to your GitHub repository, commit the changes, and push them back to the remote repository. This process ensures that your code is version-controlled and accessible to collaborators on GitHub.


Thank you...

Keep learning, exploring, and growing!....????

Ron Fybish

Developer Advocate | DevRel | Turning Founders into Thought Leaders on LinkedIn

1 年

Fantastic progress on your DevOps journey! Keep up the great work! ??

要查看或添加评论,请登录

Dnyaneshwari khapekar的更多文章

  • Day 21/90 Task: Docker Important interview Questions.

    Day 21/90 Task: Docker Important interview Questions.

    What is the Difference between an Image, Container and Engine? An image, container, and engine are all fundamental…

  • Day 20/90 Docker CheatSheet

    Day 20/90 Docker CheatSheet

    The Docker CLI For Run a New Container 2. For Manage Containers 3.

    1 条评论
  • Day 19/90 Docker for DevOps Engineers

    Day 19/90 Docker for DevOps Engineers

    Docker-Volume A Docker volume is a persistent data storage mechanism used by Docker containers to store and share data…

    3 条评论
  • Day 18/90 Docker for DevOps Engineers

    Day 18/90 Docker for DevOps Engineers

    Docker Compose Docker Compose is a tool that allows you to define and manage multi-container Docker applications. It…

    1 条评论
  • Day 17/90 Docker Project for DevOps Engineers.

    Day 17/90 Docker Project for DevOps Engineers.

    In this blog post, we'll learn what is docker file and how to create container from docker file. Dockerfile A…

  • Day 16/90 Docker for DevOps Engineers.

    Day 16/90 Docker for DevOps Engineers.

    Docker Docker is a software platform that allows you to build, test, and deploy applications quickly. Docker packages…

  • Day 15/90 Python Libraries for DevOps

    Day 15/90 Python Libraries for DevOps

    Python In-Built Libraries Python has a wide range of built-in libraries that provide developers with a variety of…

    1 条评论
  • Day 14/90 - Python Data Types and Data Structures for DevOps

    Day 14/90 - Python Data Types and Data Structures for DevOps

    Data Type Data types in Python are fundamental categories that define the characteristics and behavior of data. They…

  • Day 13/90 Basics of Python

    Day 13/90 Basics of Python

    Here, we will learn about the basics of Python. What is Python? Python is a high-level, interpreted programming…

  • Day 12/90 Linux & Git-GitHub Cheat Sheet

    Day 12/90 Linux & Git-GitHub Cheat Sheet

    Linux Commands: Git-GitHub Commands: Thank you..

社区洞察

其他会员也浏览了