Git & GitHub in DevOps

Git & GitHub in DevOps

Source Code Management Tool (PART 1)

Let's first understand that why would we get the need for this tool

Suppose a team is making a website and each member got some tasks like someone has got to design my orders page, someone got list page, etc. Now one manager manages these all things but it is very difficult to him to get changes and updates of all each and every person every second. A manager manages the version of the code. GitHub is a Distributed Version Control System, before moving to further let's first discuss about types of source code management tool.

Types of Source Code Management Tool:-

Central Version Control System:

Distributed Version Control System

Stages in GIT

  • Working Space / Working Directory: the area where the main code is written is called workspace.

  • Staging area: the area where the code is kept which has to be committed (freeze the file here).

  • Local Repository: When the file is committed it gets into the local repository.

Important Keywords:

  • Repository - A repository is a place where you have all your codes or a kind of folder or server. It is a kind of folder related to one product; changes are personal to that particular repository.

  • Server - It stores all repositories and contains metadata.

  • Commit - * Stores changes in the repository. You will get one commit ID.

    * It is 40-bit alphanumeric characters.

    * It uses SHA-1 checksum concept.

    * Even if you change one dot, commit-ID will get updated.

    * It helps you to track the changes.

    * Commit is also named as SHA1-HASH.

  • Commit-ID/ Version-ID/ Version - Reference to identify each change, to identify who changed the file.

  • Tags - Tags assign a meaningful name with a specific version in the repository. Once a tag is created for a particular save, even if you create a new commit, it will not be updated.

  • Snapshots - Represents some data of a particular time, it is always incremental i.e., it stores the changes (appended data) only, Not the entire copy.

  • Push - Push operations copies change from a local repository server/instance to a remote or a central repository. This is used to store the changes permanently in the git repository.

  • Pull - Pull operation copies the changes from a remote repository to a local machine. The pull operation is used for synchronization between two repositories.

  • Branch - * Product is the same, so one repository, but different tasks.

    * Each task has one separate branch.

    * Finally merges (codes) all branches.

    * Useful when you want to work parallelly.

    * Can create one branch based on another branch.

    * Changes are personal to that particular branch.

    * Default branch is "master".

    * The file created in the workspace will be visible in any of branch workspace until you commit. Once you commit, then that file belongs to that particular branch.

Advantages of GIT

  • Free and open source

  • Fast and small - as most of the operations are performed locally, therefore it is fast.

  • Security - git uses a common cryptographic hash function called secure hash function (SHA-1) to name and identify objects within its database.

  • No need for powerful hardware.

  • Easier branching - If we create a new branch, it will copy all the codes to the new branch.