#day8 & #day9 Task: Basic Git & GitHub for DevOps Engineers.

What is Git?

Git is a version control system for software development. It was created by Linus Torvalds in 2005 and is now widely used by developers all over the world. Git allows developers to keep track of changes made to their code over time and collaborate with others on a project. It does this by creating a repository (or "repo") where the code and its history are stored.

With Git, developers can create a new branch of code to work on without affecting the main codebase. They can also merge changes from multiple branches together and keep track of who made each change and when. This makes it much easier to work on complex projects with multiple contributors.

Git is a distributed version control system, meaning that each developer has their own copy of the repository on their local machine. This allows them to work offline and makes it easy to share changes with others. Git also integrates with a variety of tools and services, including GitHub and GitLab, which provide additional features such as issue tracking, code review, and continuous integration.

What is GitHub?

GitHub is an online platform that provides hosting for software development and version control using Git. It allows individuals and teams to collaborate on projects, track changes to code, and manage the entire software development process in a centralized location.

GitHub provides tools for managing issues, code reviews, pull requests, and testing, making it a popular choice for open-source projects, as well as private development teams. Developers can use GitHub to store and share code, collaborate on code changes, and contribute to other open-source projects.

In addition to its core functionality, GitHub also offers a variety of integrations with other tools and services, such as continuous integration and deployment platforms, code quality tools, and project management software.

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

Version control is a system that allows developers to manage changes to their codebase over time. It is a software tool that tracks changes to source code files, documents, and other digital assets, and enables collaboration among multiple contributors working on the same project.

There are several types of version control systems (VCS), including:

  1. Local version control systems: These systems are installed on a developer's local machine and track changes to files stored on that machine.

  2. Centralized version control systems (CVCS): In a centralized version control system, a single repository serves as the central hub where all changes are stored. Developers checkout files from the central repository, make changes locally and then commit those changes back to the central repository.

  3. Distributed version control systems (DVCS): In a distributed version control system, every developer has a local repository that contains the entire history of the project. This allows developers to work offline and makes it easier to collaborate with others on the same project.

Examples of version control systems include Git (a popular DVCS), SVN (a CVCS), and Mercurial (another DVCS).

Basic Git & GitHub for DevOps Engineers:

Git is a version control system used for software development to track changes in source code and collaborate with other developers. GitHub is a web-based platform that provides hosting for Git repositories and tools to manage software development projects.

Below are some basic Git and GitHub concepts that DevOps engineers should know:

Git repositories: Git uses repositories to store code and track changes. A repository is a directory where Git keeps all the files and metadata related to a project.

Cloning a repository: To work with a Git repository, you need to clone it to your local machine. This creates a copy of the repository on your computer that you can work with.

Branches: Git allows developers to work on separate branches of the codebase without affecting the main branch. This enables developers to work on new features or bug fixes without disrupting the rest of the project.

Commits: A commit is a snapshot of changes made to a Git repository. Commits are used to keep track of changes and to provide a record of the work that has been done.

Pushing and pulling: Pushing is the process of uploading changes to a Git repository while pulling is the process of downloading changes from a Git repository. These are the two main ways developers collaborate on a Git project.

Pull requests: When a developer has made changes on a separate branch and is ready to merge them into the main branch, they create a pull request. The pull request is reviewed by other developers and, if approved, the changes are merged into the main branch.

Forks: Forking a repository creates a copy of the repository on your own GitHub account. This enables you to make changes to the code without affecting the original repository.

Issues: Issues are used to track bugs, feature requests, and other tasks related to a project. They can be created by anyone with access to the repository and can be assigned to specific developers.

Releases: Releases are used to package up a specific version of the code for deployment. They can be created manually or automatically using tools like GitHub Actions.

GitHub Actions: GitHub Actions is a CI/CD tool that automates the software development workflow. It can be used to build, test, and deploy code automatically, making it an essential tool for DevOps engineers.

Understanding these basic Git and GitHub concepts will help DevOps engineers work more effectively with software development teams and manage the software development process more efficiently.

What is the difference Between Main Branch and Master Branch?

Both "main" and "master" branches in Git serve the same purpose as the main development branch for a project, but "main" is a newer term that is gradually replacing "master" as the default branch name in some Git hosting services.

Difference between Git and GitHub:

  • Git is the distributed version control system used for tracking changes in the source code in software development.

  • GitHub is the web-based platform that provides Hosting services for Git Repository.

How do we create a new repository on GitHub?

To create a new repository on GitHub, follow these steps:

  1. Go to the GitHub website and log in to our account.

  2. Click on the "New" button in the top-left corner of the screen.

  3. On the next screen, enter a name for our repository. Choose a name that is descriptive of your project.

  4. Optionally, we can add a description of our repository to give other users more information about your project.

  5. Choose whether we want our repository to be public or private. Public repositories can be viewed and cloned by anyone, while private repositories are only visible to users who have been granted access by the repository owner.

  6. Optionally, we can choose to add a README file to your repository. This file can contain information about our project, instructions for getting started, and any other relevant information.

  7. Choose a license for our repository. A license specifies the terms under which others can use, copy, and distribute your code.

  8. Click on the "Create repository" button to create our new repository.

What is the difference between local & remote repositories?

A local repository is a repository that stores in the local machine. A remote repository is a copy of the Git Repository which is stored on a service or web hosting service like GitHub.

Task:

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

    • Set Username via cmd: git config --global user.name "USERNAME"

    • Set User Email Address via cmd: git config --global user.email "userhttps://test.com"

    • Clone repository via cmd: git clone "Repository_URL"

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

    • TestFile before updated :

    • TestFile edited on the local machine, then push to GitHub Repository

Thanks for Reading

Happy Learning

#90daysofdevopschallenge