# Git Flow vs Trunk-Based — Git Fundamentals: Commits, Branches and Collaboration

Source: https://www.skillbyai.com/en/git/git-gitflow-trunk

> Compare Git Flow and trunk-based development and choose a branching strategy for your team.

## Git Flow

**Git Flow** uses long-lived `develop` and `main` branches plus dedicated `feature/`, `release/`, and `hotfix/` branches. Structured, but heavier for fast-moving teams.

## Trunk-based development

Everyone commits small, frequent changes directly to (or via very short branches into) a single `main` trunk, often behind feature flags — favored for continuous delivery.

**Quiz:** Which strategy favors small, frequent commits straight into one trunk?

- [ ] Git Flow
- [ ] Both equally
- [x] Trunk-based development
- [ ] Neither

*Answer:* Trunk-based development. Trunk-based development minimizes long-lived branches in favor of continuous integration into main.

## Final quiz 1 of 8

Final quiz

**Quiz:** What does git add do?

- [ ] Uploads to GitHub
- [ ] Deletes files
- [x] Stages changes for the next commit
- [ ] Creates a branch

*Answer:* Stages changes for the next commit. Staging selects what goes into the next commit.

## Final quiz 2 of 8

Final quiz

**Quiz:** Which command creates and switches to a new branch?

- [ ] git branch -d name
- [ ] git merge name
- [ ] git init name
- [x] git switch -c name

*Answer:* git switch -c name. -c creates the branch.

## Final quiz 3 of 8

Final quiz

**Quiz:** When does a merge conflict happen?

- [x] Two branches change the same lines differently
- [ ] A branch is renamed
- [ ] The remote is offline
- [ ] You forget git status

*Answer:* Two branches change the same lines differently. Git cannot choose between competing edits.

## Final quiz 4 of 8

Final quiz

**Quiz:** Which command safely undoes a pushed commit?

- [ ] git reset --hard
- [x] git revert
- [ ] git rebase -i
- [ ] git stash

*Answer:* git revert. revert adds a new commit that cancels the old one.

## Final quiz 5 of 8

Final quiz

**Quiz:** Which reset mode discards working changes?

- [ ] --soft
- [ ] --mixed
- [x] --hard
- [ ] --keep-history

*Answer:* --hard. --hard resets index and working tree.

## Final quiz 6 of 8

Final quiz

**Quiz:** Why avoid rebasing shared branches?

- [ ] It is slow
- [ ] It deletes tags
- [ ] It needs admin rights
- [x] It rewrites history others already pulled

*Answer:* It rewrites history others already pulled. Rewritten commits diverge from teammates' copies.

## Final quiz 7 of 8

Final quiz

**Quiz:** What does git stash do?

- [x] Shelves uncommitted changes temporarily
- [ ] Deletes the repo
- [ ] Pushes to remote
- [ ] Renames a branch

*Answer:* Shelves uncommitted changes temporarily. pop or apply brings them back.

## Final quiz 8 of 8

Final quiz

**Quiz:** Which command finds the commit that introduced a bug?

- [ ] git cherry-pick
- [x] git bisect
- [ ] git remote
- [ ] git config

*Answer:* git bisect. bisect binary-searches history between good and bad commits.
