Git and Version Control Terminology

There are different terminologies you should remember while working with Git, version control software. Like, repository, commit, SHA etc.

Terminology

Version Control System / Source Code Manager

A version control system (abbreviated as VCS) is a tool that manages different versions of source code. A source code manager (abbreviated as SCM) is another name for a version control system.

Git is an SCM (and therefore a VCS!). The URL for the Git website is https://git-scm.com/ (see how it has “SCM” directly in its domain!).

Commit

Git thinks of its data like a set of snapshots of a mini filesystem. Every time you commit (save the state of your project in Git), it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. You can think of it as a save point in a game — it saves your project’s files and any information about them.

Everything you do in Git is to help you make commits, so a commit is a fundamental unit in Git.

Repository / repo

A repository is a directory that contains your project work, as well as a few files (hidden by default on Mac OS X) which are used to communicate with Git. Repositories can exist either locally on your computer or as a remote copy on another computer. A repository is made up of commits.

Working Directory

The Working Directory is the files that you see in your computer’s file system. When you open your project files upon a code editor, you’re working with files in the Working Directory.

This is in contrast to the files that have been saved (in commits!) in the repository.

When working with Git, the Working Directory is also different from the command line’s concept of the current working directory which is the directory that your shell is “looking at” right now.

Checkout

A checkout is when the content in the repository has been copied to the Working Directory.

Staging Area / Staging Index / Index

A file in the Git directory that stores information about what will go into your next commit. You can think of the staging area as a prep table where Git will take the next commit. Files on the Staging Index are poised to be added to the repository.

SHA

An SHA is basically an ID number for each commit. Here’s what a commit’s SHA might look like: e2adf8ae3e2e4ed40add75cc44cf9d0a869afeb6.

It is a 40-character string composed of characters (0–9 and a–f) and calculated based on the contents of a file or directory structure in Git. “SHA” is shorthand for “Secure Hash Algorithm”. If you’re interested in learning about hashes, check out Intro to Computer Science course.

Branch

A branch is when a new line of development is created that diverges from the main line of development. This alternative line of development can continue without altering the main line.

Going back to the example of save point in a game, you can think of a branch as where you make a save point in your game and then decide to try out a risky move in the game. If the risky move doesn’t pan out, then you can just go back to the save point. The key thing that makes branches incredibly powerful is that you can make save points on one branch, and then switch to a different branch and make save points there, too.

Example:

First, the files will be in the working directory, then it goes to the staging index and then it goes to repository.

Working Directory -> Staging Index -> Repository

Thank You!

Stay Connected, for more tutorial series on Git and Github.

Visit: MLAIT for more updates on ML, AI and Cloud!

See : What is Version Control?

Paras Patidar

I am a Machine Learning and AI Enthusiast.

Add comment

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.