Loading lessons...
Branching and Merging Commands
These commands manage branches, merges, logs, stashes, and tags.
git branch
bash
git branch
git branch feature-x
git branch -d feature-x
Lists, creates, and deletes branches.
git checkout and git switch
bash
git switch feature-x
git switch -c new-branch
git checkout -b new-branch
Move between branches. -c/-b creates and switches.
git merge
bash
git merge feature-x
Joins another branch into your current one.
git log
bash
git log - oneline
git log - oneline -5
Shows commit history.
git stash
bash
git stash
git stash pop
Set changes aside and bring them back.
git tag
bash
git tag v1.0
git tag -a v1.0 -m "Release"
Name specific commits, usually for releases.
git worktree
bash
git worktree add ../folder branch
Add extra working folders for other branches.
TL;DR
- branch, switch, and merge manage lines of work.
- log shows history.
- stash shelves changes; tag names releases.
- worktree lets you work on several branches at once.