From "final_v2" folder chaos to Git immutability
Saving manual copies with arbitrary names causes lost code, accidental overwrites, and zero traceability. Git models the project as a directed sequence of complete, cryptographically identified snapshots.
⚠️ Zero traceability, no authors, no hashes, impossible to diff changes.
✓ Every commit points to its parent, with author, date, message, and immutable snapshot.
The three-state cycle: Working Tree, Staging, and History
A file does not jump directly from your editor to history. First it lives modified on disk (Working Tree), then it is surgically staged with git add (Staging Area), and finally it is sealed with git commit.
No pending changes.
Ready to be committed in next snapshot.
Current history in sync.
Commit anatomy: a 4-part cryptographic object
A commit does not store simple diffs. It is an immutable object pointing to a file Tree, its parent commit, author metadata, and the descriptive message.
feat: add header navigation and semantic landmarks
HEAD: the compass pointing to your current position
In Git, branches are not heavy folders: they are lightweight text pointers. HEAD is a special reference pointing to the active branch, ensuring the next commit links right where you stand.
HEAD points to main at commit C2. Every new commit will automatically advance the main pointer.
State diagnosis and history reading with status and log
Accurately interpreting git status output prevents disasters. Learn to identify Untracked files, Staged changes, and branches ahead of remote.
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: src/components/Navbar.astro
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
modified: src/pages/index.astro
Untracked files:
(use "git add <file>..." to include in what will be committed)
temp-notes.txt Files added with git add. Will be included in the next snapshot.
Files modified on disk but not yet indexed in Staging Area.
Brand-new files that Git has never tracked in this project.
Golden checklist to keep your repository pristine
Mastering Git is about discipline, not memorizing commands. Review these 4 essential architectural rules before your next commit.
Set your identity before your first commit
Git bakes user.name and user.email into each SHA-1 hash immutably. Committing with wrong emails requires rewriting history later.
git config --global user.name "Tu Nombre"
git config --global user.email "tu@email.com" Surgical staging: avoid blind "git add ."
Use Staging as a workbench: stage only files that belong to the exact same logical unit. Consider git add -p to inspect hunks.
git add src/components/Header.astro
git status Atomic and testable commits
Each commit should compile, pass tests, and serve one purpose. If you need "and" to describe it (e.g. "add login and restyle footer"), split it in two.
Branch out for every non-trivial change
Never code directly on main. Isolating features in dedicated branches lets you experiment, pivot, or discard cleanly.
git switch -c feature/auth-login