Analytics Vidhya
Published in

Analytics Vidhya

Git Part 1: Fundamentals

You are a git newbie or want to refresh your knowledge? Yeah, I can fully recommend this series to you.

Photo by Yancy Min on Unsplash

Today git is one of the most popular version control systems. One reason for this is that git offers an easy entry point. If you’re a beginner, you’ll quickly learn what a branch is and how to create it. You don’t have to get a full understanding of git first and that’s fine at the beginning. But as you dive deeper into git, you’ll be able to work much more efficiently, deal with problems and use powerful new features. In this article, you will get a basic grasp of what git is capable of and later on, we’ll delve deeper and deeper into more advanced things.

Agenda

  • What’s Git?
  • Why we should use Git ?
  • Key Terminology
  • Github/Bitbucket/Gogs…
  • Conclusion

What’s Git ?

If we check out the official Git Website, the first sentence we can read is:

Git is a free and open source distributed version control system […]

- https://git-scm.com/

This sentence might sound confusing, but don’t worry, let’s simplify this. I believe the part “Git is a free and open-source” should be mostly self-explanatory. So we will continue directly with “… distributed version control system”

Start with the meaning of version control system. The main task of a version control system is to store changes to files. Thereby we have records of all the changes that have been made and we can super easily go back to any point in history. But we read a little further up that git is a distributed version control system. On this, the base server/computer and each user have the entire history. Below you can see how it looks like.

https://git-scm.com/book/en/v2/images/distributed.png

A few years ago the standard consisted of a centralized version control system. But it had to struggle with many disadvantages. One of the biggest was the single point of failure. In a centralized version control system, the base server/computer is the only one that contained the entire history. If it is not reachable we haven’t any possibility to get our entire history. To get a better understanding check out the graphic below.

https://git-scm.com/book/en/v2/images/centralized.png

Why we should use Git ?

First of all, it’s just my thoughts. You may disagree with my opinion. So check all the points again and form your own opinion.

Now we know the meaning of git, but why should I use it? Below are my seven main reasons for using git.

  1. Access to the entire history.
  2. Simultaneous work on different features.
  3. The provided staging area is powerful and helpful.
  4. Git is widely used. The probability that you’ll need it in your career is high.
  5. Many popular repository management services use git, such as Github or Bitbucket.
  6. Git offers many tools. You can use it, but you don’t have to.
  7. And finally, getting started was very easy.

Key Terminology

In the third part, I will give you an understanding of the basic terminology. We’ll look at remote and git repositories, and see what a branch and what a commit is. So stay tuned and here we go.

Photo by Moritz Schmidt on Unsplash
  • Git Repository
    A git repository contains your entire project and all the changes you’ve made since you created your git repository. All this information is stored in the .git directory. This is generated when you create your local git repository. You can usually find it in your project folder. The .git folder contains all meta-information and the entire history.
  • Remote Repository (on Github, Gogs…)
    Github, Gogs and many other platforms offer you remote repositories. A remote repository is a clone of your local git Repo and often represents the central storage location. Today, most of them have many more features to help you and your team with daily work.
  • Branch
    In short, a Branch is just a pointer to a commit. We will find out why the sentence makes sense in a later article. For now, all you need to know is that a branch refers to a specific state of your project.
  • Commit
    A commit contains configuration details, often a reference to your last commit and the blob tree, which in turn contains references to blobs. Git uses commits to collect all changes and save them in a snapshot. Before we can commit anything, we need to add a description.
  • Merge
    Imagine you have completed a feature in your feature branch and want to put it on your master branch. In this case, git provides merge functionality. This means that we can very easily merge the changes from our feature branch with our master branch. So in short, merging means applying the changes from one branch to another one.
  • Pull Request
    Pull Request is a request to update your branch with the state of another one. You can assign it to other people and make further settings.

Github/Bitbucket/Gogs…

Finally, I will talk about repository management services that use git. There are many of them today. Repository management services have played an important role in the popularity of git. We use them to share our code, work in teams, and structure our projects. But, and this is important, these platforms use git. They’re not equal to Git.

escueladevrock.com/

Conclusion

In this article, I explained the basics of Git. By the end, you should know what Git is, why and when I should use it, the key terminology and the differences between Git and repository management services. I hope this article was helpful to get an entry or refresh your knowledge. If you have any questions or feedback, please let me know in the comments. See you soon.

In my next article, We will look at ‘Git Part 2: The Three Worlds System’.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Henry Steinhauer

Henry Steinhauer

Passionate software developer who enjoys exploring new programming languages, design patterns and frameworks.