DEV Community

Ayush Poddar
Ayush Poddar

Posted on • Originally published at poddarayush.com

Can you rebase on just the main branch? No.

πŸ“ This post is part of my "Shorts" series. Each post in this series is hyper-focused on a single concept and should take less than 1 minute to read.

In an earlier post, I introduced you to the powerful git-rebase command. The syntax for the command is:

git rebase <baseBranch>
Enter fullscreen mode Exit fullscreen mode

Rebase on anything

The baseBranch need not necessarily be a branch. It can be anything - a tag, a commit ID, relative reference to HEAD, etc.

For example, if you have a commit with ID as e92aa98f, you can do:

git rebase e92aa98f
Enter fullscreen mode Exit fullscreen mode

And voila, your feature branch’s base would change to this commit.

To be noted - for next post

The commit ID can be any commit, i.e., it can also be a commit that is already part of your feature branch. This ability to rebase on any commit is extremely useful for the purposes of rewriting history. You will find out more about this when I explore the interactive mode of git-rebase in my upcoming post.

Sources

Top comments (0)