worktree

by Clint Phillips

Follow the ▸ step. Stuck? open the hint.

Chapter 1 / 7

A repository from nothing

init · a file · add · commit

Git turns an ordinary folder into a repository — a folder with memory. Every time you take a snapshot (a commit), git remembers exactly what every file looked like, and you can return to it forever.

There are three places a file can be: your working directory (where you edit), the staging area a.k.a. the *index* (a holding pen for the next snapshot), and the commit history (the permanent record). You move files: edit → git addgit commit.

Let's make one.

  1. 1
    Turn this folder into a git repository: git init
  2. 2
    Create a file. Try: echo "# My Project" > README.md
  3. 3
    Ask git what it sees right now: git status
  4. 4
    Stage README.md for the next snapshot: git add README.md
  5. 5
    Take the snapshot: git commit -m "first commit"
chapter 1 of 70%
— bash — worktree sandbox —
worktree — a hands-on git manual
A safe sandbox. Type real git commands; nothing here touches a real repository.
New here? Follow the ▸ step in the panel on the left. Type help for every command.
 
~/project $ 

No commits yet.
Try: git initecho "hi" > readme.mdgit add .git commit -m "first"

HEAD · you are here

no repository yet — git init