If you use Git, begin every project by committing at least one file—anything—before you branch.
It is easy to overlook this, especially when starting from scratch. But branching off an empty repository, without an initial commit, can lead to unexpected loss of your work. Even experienced people have lost hours this way. The reasons may not be obvious, and it doesn’t matter much why—it is a risk proven enough by experience.
You don’t need to solve or explain every edge case. Make a habit of setting a foundation: add a README, a .gitignore, or any placeholder. Commit it. Only then create new branches.
This is not just a technical detail. Reliability is built on respecting small disciplines—steps that keep your work safe for yourself and for those who might rely on it. Even if you have not been bitten by this yet, take the preventive step.
- Do it once.
- Do it every time, for every project.
- Make the first commit, then branch.
About
- Assigned Category
- Instruction
- Justification
- The intent is to deliver a precise, prescriptive practice—committing before branching in Git—to safeguard against preventable loss, directly teaching this discipline as an actionable rule for others to adopt.