Day 8 Task: Basic Git & GitHub for DevOps Engineers.

Day 8 Task: Basic Git & GitHub for DevOps Engineers.

What is Git?

GIT is a distributed version control system used for tracking changes in source code and coordinating work among multiple developers. It was created by Linus Torvalds in 2005 and has since become one of the most popular version control systems in the software development industry.

The main purpose of GIT is to help software development teams manage and collaborate on code projects efficiently. It allows developers to work on the same codebase simultaneously, track changes made by each individual, and merge their work seamlessly. This way, it becomes easier to manage complex projects and ensure that the codebase remains consistent and stable.

What is GitHub?

GitHub is a web-based platform that provides hosting for software development projects using the Git version control system. It serves as a collaborative platform for developers to share, review, and contribute to code repositories. GitHub was founded in 2008 by Tom Preston-Werner, Chris Wanstrath, and PJ Hyett and has since become one of the largest and most popular code hosting and collaboration platforms in the world.

Version Control System and its types

Version control, also known as source control or revision control, is a system that allows developers to track and manage changes made to their code and other files over time. It provides a history of revisions, facilitates collaboration, and enables developers to work on the same codebase simultaneously without conflicts.

There are two main types of version control:

Centralized Version Control System (CVCS): In a centralized version control system, there is a single, central repository that stores all versions of the codebase and files. Developers clone a working copy from this central repository, make changes locally, and then commit those changes back to the central repository.

Distributed Version Control System (DVCS): In a distributed version control system, each developer has a local copy of the entire repository, including its full history. This means that the entire version history is distributed across all the developers' local repositories.

Why do we use distributed version control over centralized version control?

Distributed Version Control Systems (DVCS) like Git offer several advantages over Centralized Version Control Systems (CVCS) like SVN. Here are some reasons why DVCS is preferred by many developers and teams:

  1. Offline Work and Flexibility: In DVCS, each developer has a local copy of the entire repository, including the full history. This allows developers to work independently and commit changes locally even when they are not connected to a central server. They can continue to work, create branches, make commits, and track changes without interruptions caused by network issues or server downtimes.

  2. Speed: DVCS operations are generally faster because they are performed locally on the developer's machine, without the need to interact with a central server for every action. Common tasks like commit, branch creation, and history browsing are quick, enhancing productivity and reducing waiting times.

  3. Reduced Reliance on a Central Server: In CVCS, the central server is a single point of failure. If the server goes down, all development and collaboration come to a halt. DVCS eliminates this risk since every developer has a full copy of the repository. The distributed nature allows for redundancy, and multiple repositories can serve as backups.

  4. Branching and Merging: DVCS excels in managing branches and merges. Developers can create branches quickly, experiment with new features or bug fixes, and merge them back into the main codebase seamlessly. Branching is lightweight and does not impose any server-side overhead.

  5. Better Collaboration and Code Review: DVCS simplifies collaboration among developers. They can share their changes with others through pull requests or push operations. This fosters a culture of code review and ensures that changes are thoroughly reviewed before being integrated into the main repository.

  6. Support for Large Projects: As a project grows, centralized systems can sometimes become a bottleneck due to their dependence on the central server. DVCS's distributed nature makes it more scalable, as developers can share the load of hosting the repository, making it suitable for larger and more complex projects.

  7. Open Source Community and Ecosystem: DVCS, particularly Git, has gained widespread adoption, especially in the open-source community. As a result, there is a vast ecosystem of tools, services, and documentation available, making it easier to find support and resources for Git-based projects.

Overall, the decentralized nature of a DVCS allows for greater collaboration, flexibility, and security, making it a popular choice for many teams.

Task 1: Install Git on your computer.

Visit the official website to download the git, git-scm.com/downloads

Here you can select your respective Operating System and download Git.

Task 2: Create a free account on GitHub.

Open, github.com and click on “Sign Up” and enter your details. Your account will be created.

Task 3: Create a new repository on GitHub and clone it to your local machine.

Create a new public repository in your git account, Add some files and commit it.

To clone, copy the URL and clone it in your system using git clone repo_url.

Task 4: Make some changes to a file in the repository and commit them to the repository using Git.

I have made changes to the first.txt file and we can see that has been modified using the command git status. So, I have added the file in the staging area and committed it by giving a message.

Now, we can see the status as nothing to commit.

Task 5: Push the changes back to the repository on GitHub.

Let's push this code to our GitHub repo using the command git push origin main.

Check in the remote repo for the file :-

So, today we saw what are Git and GitHub, installing Git in our system, creating an account on GitHub, how to create a new repository on GitHub and clone it to your local machine, and how to push changes from local repo to remote repo.

Thanks for reading!

#devops#90DaysOfDevops#TrainWithShubham

Let's connect on Linkedin - linkedin.com/in/namya-khullar-7b5758200