How do you squash commits during a rebase?

How do you squash commits during a rebase?

a) Use git rebase -i and mark the commits you want to squash as “squash”
b) Use git squash after rebasing
c) Use git merge --squash
d) Use git squash rebase

Answer:

a) Use git rebase -i and mark the commits you want to squash as “squash”

Explanation:

To squash commits during a rebase, you use the git rebase -i (interactive rebase) command and mark the commits you want to combine with “squash.” This combines multiple commits into one, keeping the commit history cleaner.

During the interactive rebase process, you’ll be prompted to squash or reword commits as necessary.

Squashing commits is helpful for simplifying commit history before merging branches.

Reference:

Top 100 Git and GitHub MCQ Questions and Answers

Scroll to Top