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

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

What is Git?

Git is an version control systems, which allows us to track the changes in files and coordinate works on those files around multiple people. Commonly its being used for software development process to track the changes in releases.

What is Github?

GitHub, Inc. is web based a developer platform that allows developers to create, store, manage and share their code. It uses Git software, providing the distributed version control of Git plus access control, bug tracking, software feature requests, task management, continuous integration, and wikis for every project

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

Version control is a system that tracks changes to a file or set of files over time so that you can recall specific versions later. It allows you to revert files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more.

There are two main types of version control systems: centralized version control systems and distributed version control systems.

  1. A centralized version control system (CVCS) uses a central server to store all the versions of a project's files. Developers "check out" files from the central server, make changes, and then "check in" the updated files. Examples of CVCS include Subversion and Perforce.

  2. A distributed version control system (DVCS) allows developers to "clone" an entire repository, including the entire version history of the project. This means that they have a complete local copy of the repository, including all branches and past versions. Developers can work independently and then later merge their changes back into the main repository. Examples of DVCS include Git, Mercurial, and Darcs.

Why we use distributed version control over centralized version control?

  1. Better collaboration: In a DVCS, every developer has a full copy of the repository, including the entire history of all changes. This makes it easier for developers to work together, as they don't have to constantly communicate with a central server to commit their changes or to see the changes made by others.

  2. Improved speed: Because developers have a local copy of the repository, they can commit their changes and perform other version control actions faster, as they don't have to communicate with a central server.

  3. Greater flexibility: With a DVCS, developers can work offline and commit their changes later when they do have an internet connection. They can also choose to share their changes with only a subset of the team, rather than pushing all of their changes to a central server.

  4. Enhanced security: In a DVCS, the repository history is stored on multiple servers and computers, which makes it more resistant to data loss. If the central server in a CVCS goes down or the repository becomes corrupted, it can be difficult to recover the lost data.

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

Task:

  • Install Git on your computer (if it is not already installed).

  • Create a free account on GitHub (if you don't already have one).

Exercises:

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

    Sign in with your Github account.

  2. Click on right corner + sign to create directory

    1. Give repository name and choose according to your convenience whether you want to make it public or private

      1. Clone Repository on Local Machine ( Make sure GIT is already installed in your local machine.)

        git clone <repository url>( copy the repository url from github)

        Git clone GitHub repository in Gitbash

        Check you local machine whether repository cloned or not on local machine.

        1. Make Changes to a File, Commit using Git

            git status # View the changes 
            git add <filename> # Stage the changes 
            git commit -m "Your commit message here" # Commit the changes
          
        2. Push the Changes

              git push origin main  # Push changes to 'main' branch.
          

3 . Go to Github refresh it and see the changes made.

I hope this will really give you basic understanding of Git and Github.