Glossary
Git branch
A branch separates a change history before integration. It is a reference to a commit, not a second physical copy of a repository.
Short definition
A name that points to the tip of one history line.
In a typical repository, main can point to the latest approved commit and a feature branch to the latest commit of work in progress. Both branches share common ancestors and Git does not store the whole project again for each branch. A new commit moves only the branch you are currently working on.
HEAD normally points to the checked-out local branch. In detached HEAD state, it can point directly to a commit. A remote-tracking branch, such as origin/main, is local information about the last known state of a branch on a remote; it is not a remote branch you write to directly.
What it is for
Separate development, review, and deliberate integration
A branch lets you prepare a change without immediately moving the main history. It isolates a development flow, not access rights or data.
- a separate feature branch for a new feature or experiment
- a short branch for a bug fix that should pass review and tests
- comparing a change with main before a merge or pull request
- following a remote branch through an upstream and remote-tracking reference
- a safe return from an unsuccessful attempt while commits are not yet integrated
Practical example
A feature branch for a new order export
Create feature/order-export from the current main. HEAD switches to the new local branch, but main still points to the original commit. Every subsequent commit on the feature branch moves its tip while main remains unchanged.
After push, a hosting service can open a pull request from feature/order-export to main. Review and CI decide whether the branch may be merged. A branch name or pull request is not a security boundary, though: repository service and infrastructure permissions control reading, writing, and deployment.
Shell
git switch main
git switch -c feature/order-export
git push -u origin feature/order-export
git branch -vv
How they fit together
Commit, branch, and pull request in one sequence
Diagram: main → create feature branch → local commits → push and tracking → pull request → review and CI → merge into main.
- Starting main Local main points to a starting commit. Before new work, check its relationship to origin/main and how the team updates it.
- Feature branch and HEAD git switch -c creates a local branch at the current commit and HEAD starts pointing to it. Working files switch to its content.
- Local commits Every new commit moves the feature branch to a new tip. Main does not change.
- Push and tracking git push -u origin feature/order-export sends the branch and sets its upstream. The remote-tracking reference origin/feature/order-export is updated by fetching information from the remote.
- Pull request and merge A pull request is a proposal to join branches in a hosting service. After review and CI, merge joins their histories according to the chosen workflow; it is not an automatic consequence of push itself.
Important concepts
HEAD, main, feature branches, and remotes have different roles
Clear distinctions prevent unexpected history rewrites and the mistaken expectation that a branch creates a security boundary.
Movable reference
A local branch is a reference to one commit. Creating it does not create a physical copy of files or consume a second repository-sized amount of space.
HEAD and main
HEAD says what you are working on; it usually refers to the current local branch. main is only a conventional branch name, not a special security or technical type.
Feature branch and merge
A feature branch keeps related commits outside main until the team integrates them. Merge connects histories and can require conflict resolution when changes cannot be combined automatically.
Local, remote, and tracking
A local branch is your reference. A remote is shared storage, such as origin. A remote-tracking branch is a local record of the last known remote state; upstream defines the default relationship for pull and status.
Not a security boundary
The name or existence of a branch does not limit who can see code or a secret. Configure access, main protection, and deployment in the repository service and infrastructure.
Benefits and risks
An isolated change flow without a false sense of isolation
Benefits
- work on a feature without immediately changing main
- a clear target for a pull request, review, and CI
- parallel development with a shared history of ancestors
- the ability to compare and integrate a change deliberately
What to watch
- a long-lived branch can diverge from main and create a difficult merge
- confusing origin/main with a directly editable remote branch
- force-pushing to a shared feature branch without agreement
- assuming a branch hides sensitive data or bypasses permissions
Practical use
Keep a branch short and purposeful.
For an ordinary change, a short feature branch from current main is usually more practical than a long-running branch with many unrelated tasks. Regularly integrating changes from main according to the team workflow reduces surprises during final merge.
Rewriting your own unpublished feature branch with amend or rebase can make its history clearer. Once others work on the branch or a pull request depends on it, you change their commit IDs; first inspect the state with Git and agree on the next step.
Checklist
What to check when working with a branch
A branch is a simple reference, but the team workflow around it needs clear rules.
- the name briefly describes the purpose of the change and follows the team convention
- git status and git branch -vv show the current branch, upstream, and its difference from upstream
- the feature branch contains related commits, not several unrelated tasks
- rules for merge, rebase, and force push are known by the team
- access, branch protection, and secret handling are addressed outside the branch name itself
Common questions
Branches without common misconceptions
Is a branch a copy of the project?
No. A branch is a movable reference to a commit. Git shares common history and objects; the working copy only switches content according to the selected branch.
What is HEAD?
HEAD normally points to the currently checked-out local branch and through it to its last commit. In detached HEAD state, it can point directly to one specific commit.
Is origin/main the same as my local main?
No. origin/main is a remote-tracking reference stored locally as the last known remote state. Local main is a separate branch; you can see the difference after fetch and in status.
Does a feature branch protect sensitive content?
No. A branch is not a security boundary. Protect secrets with correct access control, never committing them, and immediate rotation if they leak.
How I work with changes in practice
A good workflow connects small changes, review, and verification.
My core skills describe work with PHP applications, testing, and sustainable architecture that all build on high-quality branch workflows.