Branch
You might say
I need to try a different approach, but I don't want to break the version that works now.
Develop an independent line of work without changing the main lineA branch is a movable name pointing to a series of commits. It lets a feature, fix, or experiment proceed separately and later be merged. Create branches from the right starting point and keep their purpose small enough to review.
Know first
You can say this to an AI Agent
Store current work and sync the latest main, then create a purpose-named branch for the navigation experiment. Change and verify navigation only on that branch, not main. Report the branch, its diff from main, and validation results without merging yet.
When to use it
- Build a feature separatelymain
- Fix a bug without disturbing ongoing workfeature/new-navfeature/dark-mode
- Try an experiment$ git switch mainSwitched to branch 'main'The working directory is updated to main's file version
- Prepare a release or urgent patchmainfeature
When NOT to use it
- Use one long-lived branch for unrelated workmain
- Create it from an outdated or wrong starting point⑂ test1
⑂ aaa
⑂ New branch 2A vague name makes branches hard to distinguish later - Keep finished branches forever without a reason$ git switch mainerror: Your local changes would beoverwritten by checkout.Uncommitted changes can block a switch or remain in the working directory afterward
- Assume switching branches saves uncommitted changes safelymain
Anatomy
main
feature/new-nav
HEAD → You are now in feature/new-nav
Default branches usually contain verified changes; whether direct commits are allowed depends on team rules
A new branch is created from a certain commit, and the starting point corresponds to the snapshot at that time
Can be named according to feature/function name for independent development and testing
HEAD points to the currently checked-out branch or commit, and git switch will update its point.
Variants
switch -c
git switch -c feature/new-nav
Create and switch to a new branch from the current commit
switch
git switch main
Switch the working directory to the file version of main
branch
git branch
View local branch list
branch -d
git branch -d feature/new-nav
After confirming that the branch has been merged or is no longer needed
Typical use cases
Feature branch
$ git switch -c feature/new-nav
Switched to a new branch 'feature/new-nav'
Create and switch to a new branch from the current commit
Bug-fix branch
Experiment
Release branch
Recommended tool
Web fine-tuning tool · Selector Pro
Select page elements for precise AI edits
Click a button, text, or card, note the change, then copy its exact location to AI.
Open Selector Pro website↗Further reading
Quick check
Main is stable, and you want to try a navigation approach that may be discarded. What is the safer start?
ANS Original Methods