Basic Git & GitHub for DevOps Engineers

Basic Git & GitHub for DevOps Engineers

What is Git?

Git is a distributed version control system (DVCS) designed for tracking changes in source code during software development. It enables multiple developers to collaborate on a project simultaneously, keeping track of individual contributions and allowing seamless integration of changes.

In technical terms, Git stores the complete history of a project in a repository, which contains all the files and folders associated with the project. Each developer has a local copy of the repository, enabling them to work offline and independently. Git utilizes a unique hashing algorithm to identify and track changes, ensuring data integrity and efficient storage.

A typical example of using Git involves a team of developers working on a web application. Each developer clones the central repository to their local machine using the "git clone" command. They make changes to the code, add new features, or fix bugs. Git tracks these changes using commands like "git add" and "git commit." Developers can create branches to work on separate features or experiments without affecting the main codebase. When ready, they can merge their changes back into the main branch using "git merge." Throughout the process, developers can synchronize their work with the central repository using "git push" and update their local repository with the latest changes using "git pull."

What is GitHub?

GitHub is a web-based platform that serves as a hosting service for version control utilizing the Git distributed version control system. As a subsidiary of Microsoft, it not only offers the core functionality of Git, including distributed version control and source code management (SCM), but also introduces its own unique features.

Developers widely embrace GitHub as it provides a robust and user-friendly environment for sharing and collaborating on software projects. The platform facilitates seamless collaboration among developers by enabling them to contribute to projects, review code, and propose changes through pull requests. GitHub's interface and tools enhance the overall software development workflow, making it easier to manage and track changes to codebases.

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

Version control is an essential system that tracks changes made to files over time, enabling you to access specific versions when needed. It offers numerous benefits, including the ability to revert files or projects to previous states, compare changes, identify problem-causing modifications, track issue introductions, and more.

There are two primary types of version control systems: centralized version control systems (CVCS) and distributed version control systems (DVCS).

CVCS relies on a central server to store all versions of a project's files. Developers check out files from the server, make changes, and then check them back in. Subversion and Perforce are examples of CVCS.

DVCS, on the other hand, allows developers to clone the entire repository, including the complete version history. This grants them a local copy containing all branches and past versions. Developers can work independently and subsequently merge their changes back into the main repository. Git, Mercurial, and Darcs are examples of DVCS.

What is Git Remote? What is Git's origin?

Git Remote: Git Remote is a command in Git that allows you to manage remote repositories. It lets you view, add, rename, and remove remote repositories associated with your local Git repository.

Git's Origin: In Git, "origin" is the default name typically given to the remote repository that your local repository was cloned from. It serves as a convenient way to refer to the original remote repository and is used as a default when pushing and pulling changes.

Git Commands:

Initiate git:

git init

Git origin:

git remote -v

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

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