Day 8: Basic Git & GitHub for DevOps Engineers.

Introduction: Understanding Git & GitHub for DevOps Engineers
In the world of DevOps, where speed, collaboration, and quality reign supreme, understanding Git and GitHub becomes crucial. Git is essentially a version control system that allows developers and DevOps engineers to keep track of changes made to code over time. Meanwhile, GitHub acts as a platform where this code is stored, shared, and collaboratively worked upon. This article aims to introduce DevOps engineers to the fundamental concepts of Git and GitHub, illustrating their significance in streamlining workflows, promoting collaboration, and ensuring code quality.
Whether you're new to DevOps or looking to sharpen your skills, this guide will help you grasp the key concepts of Git and GitHub, making your work more efficient.
What is Version Control?
Version control is managing the changes of documents, file or any other type of data. Its primary purpose is to track modifications to source code, documents, or any other set of files, enabling users to recall specific versions later. And Git is a most popular version controlling tool which is used in software industry.
There are two main types of version control systems: centralized version control systems and distributed version control systems.
A centralized version control system (CVCS) uses a central server to store all the versions of a project's files. Developers "check out" files from the central server, make changes, and then "check in" the updated files. Examples of CVCS include Subversion and Perforce.
A distributed version control system (DVCS) allows developers to "clone" an entire repository, including the entire version history of the project. This means that they have a complete local copy of the repository, including all branches and past versions. Developers can work independently and then later merge their changes back into the main repository. Examples of DVCS include Git, Mercurial, and Darcs.
Why we use distributed version control over centralized version control?
Better collaboration: In a DVCS, every developer has a full copy of the repository, including the entire history of all changes. This makes it easier for developers to work together, as they don't have to constantly communicate with a central server to commit their changes or to see the changes made by others.
Improved speed: Because developers have a local copy of the repository, they can commit their changes and perform other version control actions faster, as they don't have to communicate with a central server.
Greater flexibility: With a DVCS, developers can work offline and commit their changes later when they do have an internet connection. They can also choose to share their changes with only a subset of the team, rather than pushing all of their changes to a central server.
Enhanced security: In a DVCS, the repository history is stored on multiple servers and computers, which makes it more resistant to data loss. If the central server in a CVCS goes down or the repository becomes corrupted, it can be difficult to recover the lost data.
What is Git & GitHub?
Git:
Git is a version control system that allows you to track changes to files and coordinate work on those files among multiple people. It is commonly used for software development, but it can be used to track changes to any set of files.
With Git, you can keep a record of who made changes to what part of a file, and you can revert back to earlier versions of the file if needed. Git also makes it easy to collaborate with others, as you can share changes and merge the changes made by different people into a single version of a file.
GitHub:
- GitHub is a web-based platform that provides hosting for version control using Git. It is a subsidiary of Microsoft, and it offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. GitHub is a very popular platform for developers to share and collaborate on projects, and it is also used for hosting open-source projects.
Hands-On Practice: Using Git and GitHub
Based on your understanding of Git and Github, let's do some hands-on practice on them. So, following the below steps, we create one github repository, clone this repo to the local machine, and also make some changes to the file on your local machine and commit these changes to the github repo.
Step 1: Install the Git
Install Git on your computer (if it is not already installed). You can download it from the official website at https://git-scm.com/downloads
Create a free account on GitHub (if you don't already have one). You can sign up at https://github.com/
Step 2: Create a new Repository on GitHub
After login to your account click on the '+' sign and select "New repository".
Give your repository name and choose visibility (public or private), and add a brief description if needed.
Click "Create repository".
Step 3: Clone the Repository to Your Local Machine
After creating repo copy the URL of your repo and past it on you local machine (In your terminal or VS code terminal).
User the
git clone <repository_url>command for cloning your repo.
Step 4: Make some changes &commit them to the new Repository
Navigate to the directory where you cloned the repository.
create new file or use the existing file on your directory.
Now use the commands e
git add .andgit commit -m "My First Commit"
Step 5: Push the changes back to the repository on GitHub
After committing your changes locally, push them to the repository on GitHub using the below command. This command pushes the changes from your local
mainbranch to the remote repository on GitHub.git push origin mainTo verify your changes, go to your GitHub repository and see your files added or modified.
Conclusion
As DevOps continues to reshape the software development landscape, Git and GitHub remain foundational tools for ensuring efficiency, collaboration, and code quality. By understanding the basics of Git's version control capabilities and GitHub's collaborative features, explore the new commands of Git and keep doing hands-on practices on it.




