Git internalseasy0-2 years

A teammate avoids creating branches for small changes because "branching is expensive — it copies the whole project." Is that true in Git, and what does `git branch feature` actually do?

No — that advice comes from a different generation of version control, and in Git it's backwards. A branch is not a copy of the project's files; it's a single small file containing one 40-character hash, sitting in .git/refs/heads/. git branch feature writes that one file and nothing else: no files are duplicated, no objects are created, no snapshot is taken. That's exactly why creating a branch is instant regardless of the project's size, and why teams that treat branches as free — one per task, however small — aren't paying any real cost for it.

The lesson behind it →
More on Git internals