Sobes.tech
Junior — Middle

Explain what the command interactive rebase means in version control systems like Git and how it is used to edit commit history.

sobes.tech AI

Answer from AI

The git rebase -i (interactive rebase) command allows you to interactively modify the commit history in a branch. With it, you can:

  • Change the order of commits
  • Combine multiple commits into one (squash)
  • Edit commit messages
  • Remove unnecessary commits
  • Split a commit into several

When executing git rebase -i <base>, Git opens a text editor with a list of commits starting from the specified base. The user can edit commands before each commit (pick, squash, edit, etc.) to modify the history.

Example usage:

# Start an interactive rebase for the last 3 commits
git rebase -i HEAD~3

In the opened editor, you can replace pick with squash to merge commits or edit to change the commit content.

This is useful for cleaning up the history before publishing a branch, making it more readable and logical.

Explain what the command interactive rebase means in… - sobes.tech