2 Creating a Repository (git init)

Key terms/commands

  • Repository (repo): a repo tracks all the changes you made in that directory. In tangible form, it is a .git/ folder that lives inside the directory.

  • git init: creates a repository (the .git/ folder).

2.1 Create a directory call workdir in your home directory for this tutorial

mkdir ~/workdir
cd ~/workdir    

2.2 Create a repository, where git store versions of your file

Create a repository within a folder

git init
## hint: Using 'master' as the name for the initial branch. This default branch name
## hint: is subject to change. To configure the initial branch name to use in all
## hint: of your new repositories, which will suppress this warning, call:
## hint: 
## hint:    git config --global init.defaultBranch <name>
## hint: 
## hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
## hint: 'development'. The just-created branch can be renamed via this command:
## hint: 
## hint:    git branch -m <name>
## Initialized empty Git repository in /Users/runner/workdir/.git/

Check that a hidden folder .git has been created

ls -a
## .
## ..
## .git

Check the status of git

git status
## On branch master
## 
## No commits yet
## 
## nothing to commit

The status tells you have nothing to commit (last line).


You now have a repository (i.e., a .git/ folder) within a directory that you want to track!