A feature branch keeps work separate from the shared main branch. It makes changes easier to review and gives collaborators a clear place to discuss a focused task.
Start from an up-to-date branch
git switch main
git pull --ff-only
git switch -c feat/add-search-filter
--ff-only prevents git pull from creating an unexpected merge commit. If your team uses another branch naming convention, follow that convention instead.
Make and review a focused change
Check the working tree before staging:
git status --short
git diff
Stage only the files that belong to this change, then make a clear commit:
git add src/search.ts
git diff --cached
git commit -m "Add search filter"
Review the staged diff so unrelated local changes are not accidentally included.
Push and integrate
git push -u origin feat/add-search-filter
Open a pull request, describe the user-facing change, and run the project’s checks. After review and required CI pass, merge using the team’s chosen merge strategy. Delete the branch only after confirming it is no longer needed.
If main changes meanwhile
Fetch updates and follow your team’s rebase or merge policy. Before rewriting published commits, make sure collaborators are not relying on the branch. Never force-push shared work without coordinating first.