GIt: The Version Control System

What is git ?

Git is an open-source version control system. Now, you might be thinking what the heck this means... but don't worry, I will explain to you every single word that I have written like I am explaining to a 5-year-old.
* Git is just a name that has been given to this version control system, which is an open-source software maintained by some amazing developers.

* Version Control System is a system that has been developed to manage, maintain and to be in sync with your collegues and other collaborators who are working on the same project.

* There are projects, software, applications, etc being built, by some developers and their source code is made available to the public so that developers around the world can see, go through the code, fix the existing issues and contribute to the code base in order to maintain and improve the software. This is what exactly open source software means.

what is Version control ?

- version control refers to the practice of tracking and managing changes to software code, and version control system refers to software tools that assist software teams in managing changes to sources code over time.

- In layman's treams, Version Control means that if you rip off the project or accidentally delete files, you can quickly recover them, and the overhead is negligible.

HOW to use git ?

  • After installing git, open your terminal and type:
git --version

This will show you the currently installed version of git.

  • To work with git or in other words, in order for git to track all the changes in the project, you need to ask git to do that for you and how do you ask git to track your project? You simply type:
git init

This command will initialize an empty git repository for you. Basically this means that git will now start to track all the changes made in your project.

  • Git will also tell you the status of all the tracked and untracked files when you type:
git status
  • For git to add the files to it's tracking list, you will need to add the files manually by using the command:
git add file_name
# if you want to add all the files to the tracking list, then use the command:
git add .
  • After adding the files to the tracking list, you will need to cofirm that you want to make the changes permanent by commiting that change in the tracking list by using the command:
git commit -m 'commit-msg'
  • If you want to work on a differnt feature of the project that you are building and work in a way that the changes you make in your code does not change anything in the final code until you are satisfied with your work then you can create different branches by using the command:
git branch branch-name
  • You can create multiple branches and work on multiple feature independently of other features by creating multiple branches.

  • To get an overview of all the branches you or your team mates have created so far you can use the command:

git branch
  • To switch between various created branches you can use the command:
git checkout branch-name
  • To combine the work you and your friends have done you can use the command:
git merge branch-name
  • To send your changes to the production, you will need to push your code to your repository by using the command:
git push remote-repository branch-name
  • If you want to check history of everything that has happened to a git repository then you can use the command:
git log
  • Now what is this production and repository?

    • Production is the final environment in a software developement process. When a code is pushed to production then it means that all the changes made in the code is finally available for the public to use.

    • Repository is the collection of file and folder structure containing all the different versions of a project.

  • If you have to collaborate on some existing projects that is already being worked upon, then you will need to pull the code from you github or gitlab account by using this command:

git pull remote-repository-url
  • What is a remote repository?

    • A remote repository is a repository that is not on your local system but at a remote location like github or gitlab.

    • What is github and gitlab?

      • Github, gitlab and there are other services also. These are the companies that offer cloud based git repository hosting service which makes it easier to collaborate on any project.

        What is GitLab?

        GitLab is a web-based Git repository that offers open and private repositories for free, as well as problem tracking and wikis. It’s a full DevOps platform that allows developers to handle all aspects of a project, from project planning to source code management to monitoring and security. It also enables teams to collaborate and create better apps.

        GitLab enables teams to shorten product lifecycles and boost efficiency, resulting in more value for consumers. Users are not required to handle authorizations for each tool in the application. Everyone in the organization has access to every component if permissions are set once.

        What is GitHub?

        A graphical web-based Git repository hosting service is called GitHub. It is the largest coding group on the planet. When you publish a piece of code or a project on GitHub, it gets a lot of attention. Programmers can find source codes in a variety of languages and make and monitor changes using Git, a command-line interface.