What is Git and Why Use it?

In this lesson, we’ll discuss the basics of version control with git!

We’ll cover the following

  • What is version control?
  • What is Git?
  • Why Git?
    • History
    • Collaboration
    • Feature branches
    • Git in the industry

What is version control?

Managing your project’s files. For example, when building a website, you will have a lot of files, like CSS, HTML, JS, images.

Version control, also known as source control, is the practice of tracking and managing changes to software code. Version control systems are software tools that help software teams manage changes to source code over time.

What is Git?

Git is a DevOps tool used for source code management. It is a free and open-source version control system used to handle small to very large projects efficiently. Git is used to tracking changes in the source code, enabling multiple developers to work together on non-linear development.

Git is the world’s most popular version control system.

Why Git?

One of the biggest advantages of Git is its branching capabilities. Unlike centralized version control systems, Git branches are cheap and easy to merge. This facilitates the feature branch workflow popular with many Git users. Feature branches provide an isolated environment for every change to your codebase.

Git Tutorial - javatpoint

History

Git keeps track of all the changes we make to our project. Suppose you change part of the CSS, and the layout looks great, but a few months later, that change causes the layout to break in a few pages. Instead of having to remember what you changed a few months ago, Git would have a record of exactly which lines were removed/added/modified, which makes fixing the issue a lot easier. Furthermore, you can revert changes with Git. Nothing is ever lost or is ever final.

Collaboration

Git makes collaboration in a team very easy and increases productivity.

Suppose you and a team member are working together on some HTML code. In a Git-less scenario, you would write your part of the code, email the file to them; they would write their part and send it back to you. However, while they are doing their part, you won’t be able to continue working on the code. If you do, you’d have to figure out what exactly your fellow team member changed when they send it back to you and somehow merge that onto your file with your new code. This combing for changes and merging is not only tedious work but is prone to human error.

Furthermore, the time spent doing so can be spent more productively on actually writing code. The good news is that Git manages these changes and merges them for you so you and several team members can work on projects simultaneously without ever having to worry about accidentally deleting someone else’s work or merging incorrectly.

Feature branches

Git allows you to work on and ship multiple features simultaneously. For example, suppose you want to update the way your website’s navigation bar looks, and you want to add a feature that allows users to comment on your posts.

These constitute as separate features: the new navigation bar and the comments. Now in a Git-less situation, if you start working on both features and you finish the navigation bar in a week but need 3 more weeks to enable comments, you won’t be able to make your navigation bar live until the comments feature is done as well. So you would have to work on features sequentially if you want to make them live as they get completed, which means a loss in productivity.

Git, however, has the ability to make separate branches for each feature. These branches can be worked on simultaneously, and when once done, it can be merged back into the main branch.

Git in the industry

Git is the industry standard, and most employers assume that you are well versed in Git if you apply for a software job. Furthermore, it can make your time more productive and less prone to data loss even if you are working alone.

Let’s look at how to actually use Git in the next lesson!

Also Read – The Command Line Interface


That’s it!
You have successfully completed the post. Do Share : )

Peace Out!

3 Comments

Leave a Reply

Your email address will not be published.