Day 8 : Basic Git & GitHub for DevOps Engineers

Day 8 : Basic Git & GitHub for DevOps Engineers

ยท

4 min read

What is Git?

Git is a distributed version control system (VCS) designed to manage and track changes in source code during software development. Created by Linus Torvalds in 2005, Git has become the de facto standard for version control due to its speed, flexibility, and scalability. It enables multiple developers to work on a project simultaneously without conflicts, maintaining a complete history of changes.

What is GitHub?

GitHub is a web-based platform that provides hosting for Git repositories and offers collaboration features such as issue tracking, pull requests, and code review. GitHub enhances the Git experience by providing a centralized hub for developers to share and contribute to projects. It has become a central hub for open-source development and collaboration within the software development community.

What is Version Control?

Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. It helps teams manage and track changes, collaborate seamlessly, and revert to previous states if necessary. Version control systems are crucial in software development, ensuring code integrity, collaboration, and efficient project management.

How Many Types of Version Controls Do We Have?

There are primarily two types of version control systems: centralized version control (CVC) and distributed version control (DVC).

Centralized Version Control (CVC):

In CVC, a single, central server stores the entire version history. Developers check out files from this central repository, make changes, and then commit those changes back to the repository. Examples include CVS (Concurrent Versions System) and SVN (Apache Subversion).

Distributed Version Control (DVC):

DVC, on the other hand, doesn't rely on a central server. Each developer has their own local repository, including the entire project history. Git is the most popular distributed version control system, allowing developers to work independently and merge changes seamlessly.

Why Use Distributed Version Control Over Centralized Version Control?

Distributed version control offers several advantages over centralized version control, including:

  1. Offline Work: With DVC like Git, developers can work offline, commit changes, and synchronize with the central repository later.

  2. Branching and Merging: Git excels in branching and merging, enabling parallel development and streamlined collaboration without conflicts.

  3. Local Commits: Developers can make local commits before pushing changes to the central repository, providing flexibility and reducing the risk of breaking the main codebase.

  4. Redundancy and Backup: Every local repository is a complete copy of the project, providing redundancy and serving as a backup if the central server goes down.

  5. Faster Operations: DVC operations are generally faster, as developers interact with their local repositories rather than relying on a central server.

Now, let's move on to some hands-on exercises to solidify your understanding.

1. Create a New Repository on GitHub and Clone it to Your Local Machine:

  • Navigate to GitHub and log in.

  • Click on the "+" sign in the upper right corner and select "New repository."

  • Name your repository.

  • Click "Create repository."

  • Copy the repository URL.

Now, open your terminal and execute the following commands:

Clone the repository to your local machine

Clone the repository to your local machine

Navigate to the cloned directory

2. Make Some Changes to a File in the Repository and Commit Them:

  • Open a file in your preferred code editor.

  • Make some changes to the file.

  • Save the changes.

Now, in your terminal :

Check the status of your changes

Add the changes to the staging area

Commit the changes with a meaningful message

3. Push the Changes Back to the Repository on GitHub:

Now, if you visit your GitHub repository, you should see the changes reflected.

Congratulations! You've successfully created a repository, made changes, committed them, and pushed them back to GitHub. These fundamental Git and GitHub skills are the building blocks for effective version control and collaboration in DevOps workflows. Keep exploring and experimenting to deepen your understanding of these powerful tools.

I'm confident that this article will prove to be valuable, helping you discover new insights and learn something enriching .

thank you : )

ย