Git Academy

Beginner · 5 min read

Your first repository and first commit

From an empty folder to a project with a clean history.

Create the repository

git init turns the current folder into a repository (it creates a hidden .git folder). Do it once per project, at its root.

Safe
$ mkdir my-project
$ cd my-project
$ git init

Ignore what should not be versioned

Before the first commit, add a .gitignore for node_modules, build folders and secrets like .env. Our .gitignore generator in the Toolbox does it in one click.

Stage and commit

git status shows what changed. git add puts files in the next commit, git commit saves the snapshot with a message.

Safe
$ git status
$ git add .
$ git commit -m "chore: initial commit"

Look at the history

Your first commit is there. Repeat: edit, git add, git commit. Small, frequent commits are easier to understand and to undo.

Safe
$ git log --oneline