Create a Repo

In this section, we will create an empty local repo.

From now on, it's assumed that you know the basic Linux commands in the Bash shell. If you're using a Mac or Linux you can open the terminal. If you're on Windows, you can download Cmder which bundles up the Linux commands.

Examples will be simulating a Python project. Feel free to try your own content.

First, navigate to an empty folder. This is where you will put your code and work mostly. Here, I will be using a folder called git-prj under my D drive. Note that the prompt is λ and the command is whatever follows. For example, this is the input and output of pwd, which prints the working directory.

λ pwd
D:\Work\git-prj

If we do a list now, there won't be any files

λ ls -la
total 4
drwxr-xr-x 1 panflutes 197121 0 May  2 15:17 ./
drwxr-xr-x 1 panflutes 197121 0 May  2 15:17 ../

Initialise

Now use git init to tell Git to make this folder a repo, meaning Git will start tracking this folder.

λ git init
Initialized empty Git repository in D:/Work/git-prj/.git/

If we list now, you will find the .git folder. This is where Git stores all the tracking information. On Linux, files started with a dot is hidden so include -a to show all files.

λ ls -la
total 8
drwxr-xr-x 1 panflutes 197121 0 May  2 15:21 ./
drwxr-xr-x 1 panflutes 197121 0 May  2 15:17 ../
drwxr-xr-x 1 panflutes 197121 0 May  2 15:21 .git/

You don't need to interact with .git directly. The Git commands will do all the work.

Last updated