Your organization's Git policy stipulates that feature branches must be cleaned up so that only one meaningful commit is sent for review. While working on branch bugfix/issue-9273 you have created six small commits. You are still on that branch and want to combine those six commits into a single commit before pushing. Which single Git command will open an interactive editor that lets you squash those commits without affecting any other branch history?
Using git rebase -i HEAD~6 tells Git to start an interactive rebase that rewinds the branch to the parent of the sixth-latest commit and then replays those six commits. The interactive todo list allows you to mark five of the commits as squash or fixup so they are folded into the first, producing one consolidated commit and a linear history.
git merge --squash HEAD~6 only stages a squashed snapshot and still requires a separate git commit; it does not provide an interactive interface and leaves a different history shape. git reset --soft HEAD~6 moves the branch pointer backward but loses the original commit objects until a new commit is made, so it is not a squash workflow. git rebase --onto origin/main rebases the branch onto the tip of origin/main; unless the -i option plus the correct upstream range is added, it neither squashes the six commits nor opens the interactive editor.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does 'git rebase -i' do?
Open an interactive chat with Bash
What is the difference between squashing and rebasing?
Open an interactive chat with Bash
Why is 'git rebase -i HEAD~6' better than 'git merge --squash' in this case?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .