What is the different between interactive rebase, like:
git rebase -i HEAD~3
And rebase without -i
:
git rebase HEAD~3
Interactive rebase in Git is a tool that provides more manual control of your history revision process. When using interactive rebase, you will specify a point on your branch's history, and then you will be presented with a list of commits up until that point.
Git Merge Vs Git Rebase:Git merge is a command that allows you to merge branches from Git. Git rebase is a command that allows developers to integrate changes from one branch to another. In Git Merge logs will be showing the complete history of the merging of commits.
What Does Git Rebase Do? A Git rebase changes the base of the developer's branch from one commit to another, so it looks like they have created their branch from a different commit. Internally, Git creates a new commit and applies it to the specified base.
You can run git rebase --abort to completely undo the rebase. Git will return you to your branch's state as it was before git rebase was called. You can run git rebase --skip to completely skip the commit.
As Thomas Edwards commented, the docs are helpful here. As is the pro git book (specifically the sections on rebasing and rewriting history.
At it's core, a rebase will check out a root commit and apply a series of commits one by one.
When you do a regular rebase (git rebase HEAD~3
), this happens automatically.
When you do an interactive rebase however (git rebase -i HEAD~3
), you get a chance to edit the commits.
This can look like amending the commit message, squashing commits together, editing the changes in a commit or even removing commits entirely!
The interactive rebase will open an editor with a list of the commits which are about to be changed. This list accepts commands, allowing the user to edit the list before initiating the rebase action.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With