Git First Repository
In this page:
What is a Git Repository?
A Git repository is just a normal folder plus one hidden subfolder, .git, where Git actually stores the entire tracking database -- every commit, branch pointer, and piece of history lives inside that one directory, invisible during everyday work.
Example: What is a Git Repository?
git init
ls -la
Creating a Project Folder
Before you can track anything, you need a clean folder to work in: mkdir my-project creates it and cd my-project moves your terminal inside it, giving Git an empty starting point with no unrelated files to confuse it.
Example: Creating a Project Folder
mkdir my-project
cd my-project
Initializing Git in the Folder
Running git init inside that folder is the one command that actually turns a plain directory into a Git repository -- it creates the hidden .git database and nothing else, so your existing files are completely untouched.
Example: Initializing Git in the Folder
git init
Creating Your First File
With tracking active, create something for Git to actually track -- a README.md explaining the project, or a simple HTML page -- since an empty repository has nothing meaningful to commit yet.
Example: Creating Your First File
echo "# My Project" > README.md
Verifying the Hidden .git Folder
Running ls -la (note the extra -a for all, which reveals hidden files) lets you confirm the .git folder really exists; if it's missing, git init either failed or was run in the wrong directory.
Example: Verifying the Hidden .git Folder
ls -la
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: