Key Takeaways
- Branches are Pointers: A branch is just a 41-byte file pointing to a commit hash. Creating one is instant.
- HEAD is “You Are Here”: HEAD usually points to a branch name, which points to a commit.
- Merge Strategies Matter:
- Fast-Forward: No new commit (cleanest).
- No-FF: New commit (preserves history).
- Squash: New commit with combined changes (clean main history).
- 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.
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.