What command is used to edit and reorder commits with an interactive rebase?
Posted by FrankMl
Last Updated: June 07, 2024
To edit and reorder commits with an interactive rebase in Git, you use the command:
git rebase -i <commit>
Replace <commit> with the commit hash or reference (such as HEAD~n) that you want to start the rebase from. For example, if you want to reorder the last 3 commits, you would use:
git rebase -i HEAD~3
This command will open an editor where you can see a list of the commits and their messages. You can then change the order of the commits or use commands like pick, edit, or squash to modify how the commits should be handled during the rebase.
Related Content