The first thing you need to do when starting with version control for any project is to initialize it with Git. To recap from the previous tutorials, remember that, git is independent of a programming language or a framework. In this tutorial we will learn how to create a git repo using git init command.

git-init

So you are learning web development and you have a folder structure on your D: drive D:/LearningToCode/Project1/ which contains files like index.html, main.css, fn.js. You are interested in version control your Project1.

  1. Go inside the Project1 folder, right click and choose Git Bash Here.
  2. On the command line write git init
  3. Congratulations you have created your first git repo.

The init sub-command is short for “initialize”. It will do the initial setup of a repository. You will find a new folder is created under Project1 directory with the name .git. [If you don’t see the folder in your Windows machine, it may be because your OS is not configured to show hidden items. Simply click on View in the ribbon-menu on top and select Hidden items checkbox on the right side.]

.git folder IS the repo and it is the place where all the version control magic happens. This is where git records all of the commits and keeps track of everything!

This is how the contents inside .git folder would look like.

git-folder

Here is it pertinent to mention that you SHOULD NOT edit any files inside the .git directory. If you change file names or file content, git may lose track of the files that you have kept in the repo!

For you to work on git, you SHOULD NOT worry about the above folder structure or the contents of it. The above figure is just to show you under-the-hood of git. In all probability, you would never need to open this folder at all.

The power of git is contained in the various operations it can handle which we will see in the upcoming tutorials.