- develop multiple features in parallel,
- iterate on experiments, and
- isolate bug fixes until they’re ready to land.
Create a branch for each independent piece of work. Branches are cheap and let you iterate safely.
Inspecting branches
List branches in your repository:main exists:
Creating and switching branches
Create a new branch without switching to it:exploring-coloring until you merge or rebase them into main.
Example branch listing after creation and checkout:
Example changes (style and gameplay)
Imagine you want to update UI colors and increase the number of lives in a browser game. Here are representative excerpts fromstyle.css and script.js that show the changes you might make on the exploring-coloring branch.
Updated CSS variables (selective excerpt from style.css):
script.js (cleaned and corrected):
startGame function so fresh games start with five lives:
exploring-coloring and test the app. You should see the updated color scheme and five starting lives.
Staging and committing changes
Check your working tree:Useful Git commands (quick reference)
Inspecting history across branches
git log shows commits reachable from HEAD. These variations help visualize branch structure and history:
Example compact output (actual hashes will differ):
--graph and --oneline flags are especially helpful for visualizing how branches diverge and where HEAD currently points.
Before merging, ensure you don’t accidentally commit sensitive files (API keys, large binaries) and resolve any merge conflicts locally. Run your test suite or smoke tests after merging to confirm behavior.
Merging back into main
When your changes are tested and ready:- Switch to
main: - Update
mainfrom the remote: - Merge your feature branch:
- Resolve any conflicts, run tests, then push:
Links and further reading
- Git branching basics: https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
gitreference: https://git-scm.com/docs- VS Code Source Control: https://code.visualstudio.com/docs/editor/versioncontrol
By using a dedicated branch like
exploring-coloring, you keep your experiments isolated from main, enabling safe iteration and easier collaboration. When ready, merge via PR or locally following your team’s workflow.