Basic Git & GitHub for DevOps Engineers

Table of contents
- π€ What is Git?
- π What is GitHub?
- π’ What is Version Control?
- π Why Do We Use Distributed Version Control Over Centralized Version Control?
- π Task 1: Install Git
- π€ Task 2: Create a GitHub Account
- π Exercise 1: Create a New Repository on GitHub
- π Exercise 2: Clone the Repository to Your Local Machine
- π Exercise 3: Make Changes, Commit, and Push

Hey there, DevOps Engineers! Welcome to Day 8 of your journey, where we'll dive into the world of version control with Git and GitHub. π
π€ What is Git?
Git is like a magic wand for developers! It's a version control system that allows you to track changes to your files and collaborate seamlessly with your team. Whether you're working on software projects or any other set of files, Git has got your back!
π What is GitHub?
GitHub, on the other hand, is the enchanted castle that hosts Git repositories. π° It's a web-based platform that makes version control a breeze. Microsoft's subsidiary, GitHub, offers all the functionalities of Git and adds its own amazing features. It's a favorite among developers for sharing, collaborating, and hosting open-source projects. π
π’ What is Version Control?
Version control is like a time machine for your files! π It keeps track of all changes made over time, allowing you to recall specific versions whenever you need. With version control, you can easily revert files, compare changes, and identify who did what, making it an indispensable tool for developers.
π€·ββοΈ How Many Types of Version Control Systems?
There are two main types of version control systems:
Centralized Version Control System (CVCS) π― In this system, all files' versions are stored on a central server. Developers "check out" files to make changes and then "check in" the updates. Examples: Subversion and Perforce.
Distributed Version Control System (DVCS) π In the DVCS world, each developer gets a complete copy of the repository, including its entire history. This means more freedom and less dependency on a central server. Examples: Git, Mercurial, and Darcs.
π Why Do We Use Distributed Version Control Over Centralized Version Control?
π₯ Better Collaboration: With a DVCS, everyone on the team has a full copy of the repository. This fosters seamless collaboration without the constant need to communicate with a central server.
β‘ Improved Speed: DVCS allows developers to work faster. They can commit changes and perform version control actions more swiftly as everything is available locally.
π§ Greater Flexibility: Work offline? No problem! DVCS lets you work independently and share changes later when you're back online. You can also choose who to share your changes with, giving you more control.
π‘ Enhanced Security: With DVCS, your repository's history is stored on multiple servers and computers, making it more resilient to data loss. Unlike CVCS, you won't lose everything if the central server has issues.
π Embrace Git and GitHub, and you'll unleash the true power of version control and collaboration! So go ahead, start exploring, and let Git and GitHub be your allies on the DevOps journey! Happy coding! ππ¨βπ»
π Task 1: Install Git
π Go to git-scm.com/downloads, the official Git website.
π₯ Download the installer that matches your operating system.
πββοΈ Run the installer and follow the on-screen instructions to finish the installation.
β 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.
π€ Task 2: Create a GitHub Account
π Open your web browser and go to github.com.
π±οΈ On the GitHub homepage, click on the "Sign up" button.
π Fill in the required information, like your username, email, and password.
πΌ Choose a plan that suits you (Free or one of the paid options) based on your needs.
π 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.
π Exercise 1: Create a New Repository on GitHub
π 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.
π Exercise 2: Clone the Repository to Your Local Machine
π Go to your repository page on GitHub and click on the "Code" button.
π Copy the repository URL.
π₯οΈ Open the terminal or command prompt on your computer.
π Navigate to the directory where you want to save the repository.
π₯ Use the command "git clone" followed by the repository URL you copied. For example: git clone github.com/your-username/your-repository.git
π Press Enter, and the repository will be cloned to your local machine.
π Exercise 3: Make Changes, Commit, and Push
πΆββοΈ Move to the repository directory.
π Create two files using the touch command.
π Use the command "git status" to see the changes you made. It will show the modified files.
β 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.
πΌ Use the command "git commit" to save the changes with a meaningful message describing the modifications. For example: git commit -m 'Added new files'
π 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.
π Conclusion π Congratulations! You've completed Day 8 of the #90DaysOfDevOps challenge. Today, you gained a solid understanding of Git and GitHub, covering tasks like creating repositories, cloning them locally, making changes, committing, and pushing back to GitHub. These core exercises are crucial for version control and collaborative software development. Keep up the fantastic work! ππ
π’ Stay in the βοΈ cloud loop and blast off into the π DevOps universe! Join me on Hashnode, where I share my latest insights and articles about all things cloud and DevOps. Let's connect on LinkedIn (https://www.linkedin.com/in/nirmal-mahale-605565215/) and explore the boundless possibilities of the tech cosmos together. π And hey, if you want to peek under the hood of my projects, hop on over to my GitHub (https://github.com/nirmal7030). π οΈ
Subscribe to my newsletter
Read articles from Nirmal Mahale directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Nirmal Mahale
Nirmal Mahale
Passionate about Python, Cloud Computing, and DevOps. Architecting robust cloud solutions, mastering AWS & Azure, and automating with cutting-edge DevOps tools. Join me on this journey of innovation and collaboration. Let's shape the future together!