Skip to content

Document Git habit: every branch starts from an up-to-date main #69

Description

@ieliofficial

A git habit worth fixing, because it explains a lot of what went sideways on the name-change PR #68.

When you're a few days into a feature branch and I ask for something small and unrelated, like renaming a variable, the small change needs to start from main, not from the branch you're currently sitting on. Right now you're creating the new branch on top of the old one, so it carries every commit from that unfinished work. The PR then shows your rename plus days of unrelated changes, it can't be reviewed on its own, and it can't merge until the other branch merges first.

The habit is: go back to main, pull, then branch.

git switch main
git pull
git switch -c fix/rename-thing

If you've already built the branch on the wrong base, you don't have to redo the work. You can move just your commits onto main:

git rebase --onto main <old-branch> <new-branch>

Rule of thumb: one branch, one reason to exist, and its base is main unless the work genuinely depends on another branch that isn't merged yet. If you ever aren't sure what your branch is actually sitting on, git log --oneline main..HEAD shows you exactly which commits you're adding. If that list has commits you didn't mean to include, the base is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions