Git Internal Architecture
Git Internal Architecture : Working Tree, Index, and HEAD If you’ve ever wondered how Git really works internally , understanding these three core areas will completely change how you use Git: Working Tree (Working Directory) Index (Staging Area) HEAD (Current Commit Reference) Mastering these concepts will help you understand: Why git add is necessary How commits actually work What happens during git reset Why merge conflicts occur What “detached HEAD” means 1. What is the Working Tree in Git? The Working Tree (also called Working Directory) is the actual project folder on your computer — the files you see and edit. When you: Create a file Modify a file Delete a file You are changing the Working Tree . Example echo "Hello Git" > file.txt Now file.txt exists in your working directory, but Git is not tracking it yet. Check the status: git status You’ll see: Untracked files: file.txt At this point: Working Tree → modified Index → unchanged HEAD → unchanged Key I...