Lesson 56 +15 XP

Branching and Merging Commands

Branching and Merging Commands

These commands manage branches, merges, logs, stashes, and tags.

git branch

git branch
git branch feature-x
git branch -d feature-x

Lists, creates, and deletes branches.

git checkout and git switch

git switch feature-x
git switch -c new-branch
git checkout -b new-branch

Move between branches. -c/-b creates and switches.

git merge

git merge feature-x

Joins another branch into your current one.

git log

git log --oneline
git log --oneline -5

Shows commit history.

git stash

git stash
git stash pop

Set changes aside and bring them back.

git tag

git tag v1.0
git tag -a v1.0 -m "Release"

Name specific commits, usually for releases.

git worktree

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.