Git Basics: Put a Project Under Version Control From Scratch
It is a nice Monday, sun and everything, and Niki feels good about it. First day at a new job, and the plan was to walk in calm, professional, a person who already has this figured out. The plan survives for about four minutes.
Her badge is not working yet, so one guy from sales opens her the door. On her desk there is a laptop, one 404 LABS sticker, and nothing else. The company is eleven people. The product is beacon-api and according to the pitch deck it will change how fleet operators track their vehicles. According to the reality, it is a folder on a shared drive.
Not one folder, actually. There is beacon-api-FINAL-v2-actual, there is beacon-api-old-DO-NOT-DELETE, and there is beacon-api-backup.zip on the desktop of a developer who no longer works here. This is the version control so far. When somebody needs the latest code, they ask in Slack which folder is the real one, and the answer is not always the same.
First message comes from Teo, the backend lead, who is apparently also her mentor. He announces this with a wave emoji, and after thirty seconds, with a task.
"welcome! ok so. beacon-api has no repo. it is just... files. put this under version control before you touch anything. seriously, before ANYTHING"
The real folder, Teo confirms, is ~/beacon-api-FINAL-v2-actual. Everything else is history that nobody wrote down.
Niki has used git before. She cloned things, she pulled things, she pushed things when somebody told her to push now. But starting a repository from zero, this she never did.
So Niki Opens the Folder
Teo's second message arrives before she finishes reading the first: 404 Labs uses main as the branch name for every repository, not the older default a bare git init would pick. Niki initializes ~/beacon-api-FINAL-v2-actual right here, making sure it starts on main from the first commit, not something to rename afterward.
Teo's tip
git init -b main does it in one move, and works the same regardless of what this machine's own init.defaultBranch config happens to be set to. If you already initialized on another branch name, git branch -m main renames whatever branch you are currently on.
Every Commit Needs an Author
A commit needs an author, and right now ~/beacon-api-FINAL-v2-actual has none of its own, whatever name the laptop happens to answer to by default. Niki sets her own identity right here, inside this one repository, not the global settings that would follow her to every future project on the machine: name Niki, email niki@404labs.
Teo's tip
git config user.name "..." and git config user.email "..." inside ~/beacon-api-FINAL-v2-actual. With no scope flag, that writes to .git/config, local to this one repository. --global would write to ~/.gitconfig instead, which every repo on this machine inherits unless its own local config overrides it. The check here only reads the local value.
The First Commit
Everything in ~/beacon-api-FINAL-v2-actual gets staged and committed in one shot, nothing left behind, nothing still untracked.
Almost six. Teo is two desks over, headphones on, already onto the next thing. The real folder has a history now. That part, at least, is done.