Basic Git & GitHub for DevOps Engineers.

Basic Git & GitHub for DevOps Engineers.

·

3 min read

Task 8 of #90daysofdevops challenge

What is Git?

  • Git is a free and open-source version control system tool used to handle small to very large projects efficiently.

  • It is generally used for source code management in software development.

  • Git is used to tracking changes in the source code.

  • It allows multiple developers to work together. It supports non-linear development through its thousands of parallel branches.

What is Github?

  • GitHub is a web-based platform that provides hosting for version control using Git. It offers all of the distributed version control and source code management (SCM) functionality of Git with its add-on features.

  • GitHub is a very popular platform for developers to share and collaborate on projects, and for hosting open-source projects from anywhere.

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

  • Version control systems are a category of software tools that helps in recording changes made to files by keeping a track of modifications done in the code.

  • It helps in reverting files to a previous state, reverting the entire project to a previous state, comparing changes over time, seeing who last modified something that might be causing a problem, who introduced an issue and when, and more.

  • Types of version controls:

    1. A centralized version control system (CVCS): uses a central server to store all the versions of a project's files.

      e.g. 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.

      e.g. Git, Mercurial, and Darcs.

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

  1. Better collaboration

  2. Improved speed

  3. Greater flexibility

  4. Enhanced security

Excercise:

  1. Install Git on your local system (if it is not already installed). You can download it from the official website at git-scm.com/downloads

  2. Create a free account on GitHub (if you don't already have one). You can sign up at github.com

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

    1. To create new repository in GitHub, go to 'your repositories' in profile and press new button on top right corner. This will let you to following page

    2. Put here your repository name which is unique, add description if you want.

    3. Click public so that repo will be accessible to anyone.

    4. You can add README File to showcase what's this repo is all about & here is your repo created successfully.

    5. Now get inside the repo and press add file dropdown it and choose create new file file.txt and repo_list.md

    6. Now clone this repository by using command

      git clone https://github.com/<username>/<repository-name>.git

      Make sure the directory at which you want to initializes the git .

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

    1. Make any changes in files and check the status as below

      (In this, file listed in red that means it must be added to the repository)

    2. Now add this changed file & commit this changes to the repository by using command git add . && git commit -m "modified the file"

  5. Push the changes back to the repository on GitHub by using command

    git remote add origin <repository-name> && git push origin master

    Thus if refresh github we can see it gets updated.

    That's all.

Reference video: https://youtu.be/AT1uxOLsCdk

Reference articles for commands: https://www.geeksforgeeks.org/top-12-most-used-git-commands-for-developers/


Thanks for reading.

Keep learning & stay connected!!