Branches and Pull Requests
Main is what production runs, so it only changes through a pull request with green tests. Here is the workflow and why each rule exists.
Main is production
On this site, main and production are the same thing: every push to main is built and deployed automatically. So the most important Git rule is simple: never commit directly to main. Every change goes on a branch and arrives through a pull request.
This is not bureaucracy. It is the only place where a change can be checked by a machine before it reaches visitors.
Naming branches
A branch name should say what kind of change it is and what it touches:
| Prefix | Use it for | Example |
|---|---|---|
feature/ |
Something new | feature/devops-section |
improve/ |
Making something existing better | improve/homepage |
fix/ |
A bug | fix/health-sitemap-pictures |
content/ |
Writing only | content/india-batch-05 |
chore/ |
Housekeeping | chore/guards |
Months later, the branch list alone tells you what was going on.
Keep branches short-lived
A branch that lives for weeks drifts away from main. When it finally merges, conflicts pile up and the change is too big to review. A branch should do one thing and merge within a day or two. Big work is split into a sequence of small branches, each one safe to ship on its own.
The pull request as a gate
A pull request (PR) is a proposal: "merge these commits into main". GitHub runs the test workflow against it and shows a green tick or a red cross. The rule here: merge only when the tests workflow is green.
Even on a one-person project, the PR page is useful:
- it shows the full diff in one place, which is the best moment to spot a file you did not mean to include;
- its description is where the status of the work is written down (what changed, how it was tested, what is left), instead of in loose notes that go stale;
- the merge creates a single, named point in history to come back to.
Merging
There are three ways to merge on GitHub: a merge commit, squash, or rebase. This site uses ordinary merge commits ("Merge pull request #75 from ..."). The advantage is that history shows exactly which commits arrived together, and a whole PR can be found and, if needed, reverted as one unit.
Undoing a merged change
Because every change is a PR, undoing one is clean:
git revert -m 1 <merge-commit-id>
This makes a new commit that reverses the merge. It goes through the same PR and pipeline as any other change. Never rewrite the history of main with a force-push: other copies of the repository, and the deploy history, still point at the old commits.
Working on two things at once
Sometimes two pieces of work are in flight. Switching branches back and forth in one folder risks mixing files. Git's worktrees give each branch its own folder from the same repository:
git worktree add ../site-devops feature/devops-section
Each folder has its own checkout, and each branch still merges through its own PR.
Try it yourself
Look at your last ten commits on your main branch. How many arrived without a pull request? How many PRs merged with failing or missing checks? If either number is above zero, protect the branch: in GitHub, Settings → Branches can require a pull request and passing checks before anything merges.