Background

When I joined the small company that I currently work for, I was suprised at how little some of my coworkers knew about Git. The fact is, there was no reason to be suprised. I had taken my exposure with Git for granted due to the fact that I had been using it for a couple of years before I joined the firm. So as a good citizen, I prepared a little workshop to help others learn.

Now that I think about it, I could just spread the love further by sharing the stuff here on my blog too.

Git is a source control management software, lets you track changes made to your source code over time.

If you didn’t follow that, then let me explain that in the simplest possible way by combining definitions that I have found from different parts of the world wide web.

Version Control

Version Control system is a software that alows us to do the following things:

  • Store data
  • Track changes to that data
  • Track and view historical changes
  • Distribute data and the change history with those collaborating in the project

A lot of times I have seen engineers starting to use Git or another SCM like Git, by jumping straight to using a graphical user interface that abstracts all the underlying workings of it. This is a great way to start learning something poorly and to start imagining the tool as some sort of sorcery! I Think XKCD has done a really good job at depicting this in a comic in the image below.

A comic coversation between engineers about git. It is an extremely powerful collaboration tool but those who do not understand it think that in case of a conflict, you have to delete the repository and start all over again

Git is cool but not many people take the time to understand how it works

Git is built on a whole load of commands that do very specific things. It has a Linux origin story that can be found here: Getting Started: A Short History of Git

Git is a version control system that was build with performance and distributed application development in mind.

  • Everything in Git is check-summed and referred to using this check-sum
  • You create local copies of the original repository, making it easy to start working without having to connect to the main server, so long as you have your local copy
  • High performance as every operation in git is only limited by the speed of your disk I/O

Git stores data very differently when compared to other version control systems. Most other systems store information as a set of files and changes made to those files, which the git book calls: delta-based. In these systems, each file is versioned. Whereas Git on the other hand, stores a stream of snapshots of the repository, where each change is a different snapshot. You can find a pictorial depiction here - Getting Started: What is Git?

A typical developer workflow at a company might look like this:

You make changes in your local workstation and commit, then push changes to the main repository, where you then create requests for review and code gets merged.

Your workstation to a repository considered to be the canoncial source of truth

Installation

Obviously before you go ahead, you have to download and install git. Get it from here: https://git-scm.com/downloads

The installation is generally straightforward, but if you haven’t figured out the differences between line endings etc are, then here are a few guidelines when installing Git on Windows.

  • Choose your SSH Client
  • Learn about configuring SSH here: Git on Windows (search online for linux version)
  • Choose your editor
    • you could configure this later, but if you already have a favourite, make that choice.
  • This could be anything
    • vim, emacs, vscode, nano, atom etc.
  • Choose your line endings:
    • If you work on windows and deploy to linux - pick the following:
      • checkout windows style, commit unix style
  • Choose what modifications are done to your PATH variable
    • choose recommended option to keep it simple

Git Bash

Git Bash

Git Bash - runs mintty, a terminal emulator and runs a bash emulatioin which understands some linux commands, in addition to your standard windows commands

Try opening git bash. If you want to configure your prompt and other things, you could clone my repository - https://github.com/lonelydev/windows-gitbash-configuration.

Git bash is very much like cmd (command prompt). But it understands not only your windows commands but also your linux commands.

Let us dive deeper in the next post where we delve into the basics.