Key Takeaways

  1. Branches are Pointers: A branch is just a 41-byte file pointing to a commit hash. Creating one is instant.
  2. HEAD is “You Are Here”: HEAD usually points to a branch name, which points to a commit.
  3. Merge Strategies Matter:
    • Fast-Forward: No new commit (cleanest).
    • No-FF: New commit (preserves history).
    • Squash: New commit with combined changes (clean main history).
  4. Conflicts are Decisions: They happen when two branches change the same line. You must manually choose the winner.

Interactive Flashcards

Click to flip the card and test your memory.

HEAD

A pointer to the current branch reference (or commit) you are working on.

Detached HEAD

When HEAD points directly to a commit hash instead of a branch name. New commits here will be lost!

Squash Merge

Combines all commits from a feature branch into a single commit on the target branch.

Cheat Sheet

Command Description
git switch <branch> Switch to an existing branch.
git switch -c <name> Create a new branch and switch to it.
git merge <branch> Merge the specified branch into current HEAD (defaults to FF).
git merge --no-ff Force a merge commit (create a bubble).
git merge --squash Squash changes into one commit (staged, not committed).
git branch -d <name> Delete a branch safely (must be merged).
git branch -D <name> Force delete a branch (even if unmerged).

Next Steps

Now that you understand how to manage parallel work streams, let’s dive into more advanced Git concepts.

Git Glossary