🌿 Branch & Switch: Create, Rename and Shelve Work
Branch & Switch: Create, Rename and: A Git branch is like a parallel universe copy of your codebase that costs nothing to create — you are not duplicating files, you are only mov
A Git branch is like a parallel universe copy of your codebase that costs nothing to create — you are not duplicating files, you are only moving a pointer one step sideways, the same way a train switches track without physically duplicating the train. The thought-provoking question before you write a single branch command: if your work takes three hours, why not just commit directly to main and be done? Because in a QA team, main is the branch CI deploys from — one broken test file pushed directly to main fails every colleague's build and blocks the release pipeline until it is reverted. Java analogy: think of each branch as a separate thread with its own stack frame — threads in Java share heap memory until you explicitly synchronize, but each branch in Git keeps its own isolated snapshot and only merges when you decide to call join(). The real automation cost of skipping branches shows up during incidents: without a clean branch per fix, cherry-picking a specific bug fix to a hotfix release means manually hunting which commits to include instead of just merging one targeted branch.
Git Branch & Merge Flow
1) Branch creation: main stays safe
See what each branch command changes: list local branches, create `hasan`, switch to it, rename it, then push with upstream.
List and create a branch without switching
Try it now in the real terminal on the Git Basics tab: create a new branch and switch onto it (`git branch`, `git switch`/`git checkout`) — the sandbox's "Create a new branch and switch onto it" mission asks for exactly this.
Create and switch in one step, then rename and confirm
Micro Lab: git branch
Replace the TODO line with the real `git switch -c` command. The sandbox does not run a real repo; the goal is to build the correct command structure by hand.
Step by Step: git branch
List existing branches
Run `git branch`: the `* develop` line shows the currently active branch.
Run `git switch -c bugfix/login-timeout` to create the new branch and move onto it instantly.
Run `git branch -m bugfix/login-timeout-fix` to rename ONLY the active branch.