Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between interactive rebase and normal rebase?

Tags:

git

git-rebase

What is the different between interactive rebase, like:

git rebase -i HEAD~3

And rebase without -i:

git rebase HEAD~3
like image 204
Fariman Kashani Avatar asked Apr 03 '18 09:04

Fariman Kashani


People also ask

What is interactive rebase?

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.

What is the difference between git rebase?

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 git rebase exactly does choose?

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.

How do I get out of interactive rebase?

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.


2 Answers

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!

like image 85
Matthew Hallatt Avatar answered Sep 19 '22 13:09

Matthew Hallatt


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.

like image 24
Naltamer14 Avatar answered Sep 16 '22 13:09

Naltamer14