5 exercises on the precise Git vocabulary every developer needs: squash, cherry-pick, rebase, revert, force-push — what each means and when to use it.
Key Git verb collocations
squash commits → combine multiple commits into one
cherry-pick a commit → apply one specific commit to another branch
rebase a branch → replay commits on top of another branch
revert a commit → undo with a new commit (safe, keeps history)
force-push → overwrite remote history after a rebase
0 / 5 completed
1 / 5
A developer wants to combine 6 small work-in-progress commits into one clean commit before merging. Which verb is correct?
"Let's ___ those 6 commits into one before we merge."
Squash — the standard Git term for collapsing multiple commits:
"Squash" means taking multiple commits and combining them into a single commit. It's done with git rebase -i (interactive rebase) or via a "squash and merge" strategy in GitHub/GitLab.
Key Git commit collocations:
squash commits → combine multiple commits into one
amend a commit → modify the most recent commit (git commit --amend)
revert a commit → create a new commit that undoes a previous one
cherry-pick a commit → apply a specific commit from another branch
sign a commit → add a GPG signature for verification
Why squash? A clean commit history is easier to read, bisect, and revert. "squash and merge" is a popular strategy in GitHub that compresses an entire PR into one commit on main.
Why not "merge"? Merge combines branches, not commits within a branch. You merge a branch; you squash commits.
2 / 5
A new bug was introduced by a commit three days ago. A developer wants to apply just that specific commit's fix from the hotfix branch to the main branch. What verb describes this operation?
Cherry-pick — apply a specific commit from another branch:
git cherry-pick <commit-hash> applies a specific commit to the current branch without merging the entire source branch. It's the surgery of Git — precise, targeted.
When cherry-pick is used:
A hotfix was merged into a release branch — apply the same fix to main
One useful commit is buried in a messy PR — grab just that commit
A feature branch has useful work but also risky changes — cherry-pick only the safe parts
Related Git operations vocabulary:
cherry-pick a commit → apply one specific commit to another branch
rebase a branch → replay commits from one branch on top of another
merge a branch → combine two branches with a merge commit
patch a file → apply changes from a diff/patch file
Caution: Cherry-picking creates a new commit with a different hash, which can cause confusion if the original commit is later merged. Used mainly for hotfixes and backports.
3 / 5
During a code review, a reviewer writes: "This branch needs to be ___ed before merging — it has conflicts with main."
Which word completes the sentence most naturally?
Rebase — reapply commits on top of another branch:
"Rebase" means moving or replaying a branch's commits on top of another branch. If your feature branch is behind main by 20 commits, rebasing makes your branch's commits appear after those 20 commits — resolving conflicts in the process.
Rebase vocabulary:
rebase a branch onto main → update your branch so it starts from main's latest commit
interactive rebase (git rebase -i) → edit, squash, reorder, or drop commits
rebase conflicts → merge conflicts that arise during rebase
force-push after rebasing → since rebase rewrites history, the remote needs a force push: git push --force-with-lease
Rebase vs. Merge:
merge → creates a merge commit, preserves exact history, safe for shared branches
rebase → linear history, no merge commit, rewrites commits — avoid on shared branches
PR comment patterns: "Needs rebase" / "Please rebase on main" / "Conflicts — can you rebase?"
4 / 5
A developer accidentally pushed sensitive credentials to a public GitHub repository. The security team says: "We need to ___ that commit from history entirely — not just revert it."
Which phrase correctly describes the goal?
Purge / remove from history — for security incidents requiring history rewrite:
When credentials, keys, or sensitive data are pushed, the standard goal is to purge or remove from history — because a revert only adds a new commit undoing the change, but the original commit (with the secret) is still visible in the history.
Tools used for history purging:
git filter-branch → older approach, modifies history
git filter-repo → modern, faster alternative
BFG Repo Cleaner → popular tool for removing secrets from history
After purging, you must:
Force-push all affected branches: git push --force
Notify all collaborators to re-clone (their local copies still have the old history)
Rotate the compromised credentials immediately — assume they were already exposed
Vocabulary to know:
rewrite history → change existing commits (dangerous on shared repos)
force-push (git push --force) → overwrite remote with local history
purge from history → completely remove from all commits
revoke and rotate credentials → the mandatory security response
5 / 5
A team uses trunk-based development. The tech lead says: "Don't ___ long-lived feature branches — use feature flags and commit directly to main."
Which verb best fits the blank?
Maintain long-lived branches — the anti-pattern this sentence warns against:
In trunk-based development, the goal is short-lived branches merged frequently. The phrase "maintain long-lived feature branches" describes the anti-pattern — branches that live for days or weeks accumulate merge conflicts and integration risk.
Git branch lifecycle collocations:
create / cut a branch → start a new branch from main/trunk
maintain a branch → keep it updated and conflict-free over time
merge a branch → integrate it back into the target
delete / clean up a branch → remove after merging
stale branch → a branch with no recent commits, possibly forgotten
Branch naming vocabulary:
feature/, fix/, hotfix/, release/, chore/ — common prefixes
"tracking branch" → local branch following a remote branch
"upstream branch" → the remote branch your local branch tracks
Related concepts: trunk-based development, feature flags, branch-by-abstraction — all alternatives to long-lived feature branches.