Branching
You run git branch dark-mode and a second 41-byte file lands next to the first, holding the identical 40-character hash. Your whole project, every file, was left exactly where it sat, and it finished instantly.
- ▸Creating a line of work costs a 41-byte file and a log line, and copies nothing, even in a repo with a million files.
- ▸Switch and every file on disk is rewritten to another commit's snapshot, yet your saved commits never move.
- ▸
git branch -drefuses to delete when it would strand commits; the safety is a check, not what gets removed.
Your project sits on main with three files, app.py, config.json, and README.md, and one commit behind them. You want to try a redesign without touching what already works. Run git branch dark-mode. Now list the folder git keeps beside your code: .git/refs/heads/ holds two files where a moment ago it held one, main and dark-mode, and cat on each prints the identical 40-character hash. Creating dark-mode wrote two small files and nothing else: the 41-byte branch file, forty characters of that hash plus a newline, and a one-line log of where the branch started, .git/logs/refs/heads/dark-mode, ending branch: Created from main. Nothing in app.py, config.json, or README.md was copied. That is why the command returns instantly whether your project has three files or three hundred thousand: it never touches your project's files at all, it only writes a tiny file naming the commit you are already on, plus that one log line. Older tools made a whole second copy of the working folder to begin a separate line of work; here the cost is 41 bytes and a log line.