Initiate Git repository

Initializing a new git repository is as simple as

  1. open a terminal,
  2. create a new directory or go to an existing directory,
  3. run git init

Linux and MacOS

Assuming we are going to initialize a new repository in a new directory ~/projects/myrepo. We run

1
2
3
$ mkdir ~/projects/myrepo
$ cd ~/projects/myrepo
$ git init

After it, a hidden directory .git is created

1
2
$ ls -a ~/home/projects/myrepo
.git

Windows

Use Git CMD as the terminal. Assuming we are going to initialize a new repository in a new folder %USERPROFILE%\Documents\myrepo. We do

1
2
3
C:\> mkdir %USERPROFILE%\Documents\myrepo
C:\> cd %USERPROFILE%\Documents\myrepo
C:\> git init

A hidden directory .git is created

1
2
3
4
5
6
7
8
9
C:\> dir /a:h
 Volume in drive C has no label.
 Volume Serial Number is 1AC2-CFF3

 Directory of C:\Users\Hong\Documents\myrepo

02/11/2023  06:15    <DIR>          .git
               0 File(s)              0 bytes
               1 Dir(s)  13.321.207.808 bytes free