Skip to main content

Command Palette

Search for a command to run...

Git rebase to modify multiple local/remote commits at once

Published
1 min read
Git rebase to modify multiple local/remote commits at once
A

As a Senior Principal Engineer at CVSHealth, I specialize in building and optimizing cvs.com to deliver a superior guest experience. Using the latest web technologies, my team and I work diligently to create a user-friendly and intuitive platform that exceeds expectations.

The git rebase command with --exec flag can be pretty handy in a variety of situations. Using this, you can execute any git command on a range of commits, both for local and remote commits.

One example that this can be really handy for is modifying commit details.

git rebase HEAD~2 --exec "git commit --amend --no-edit --author='FirstName LastName <author@gmail.com>'"

The above commit modifies the author details on the last 2 commits in the current branch. --no-edit flag ensures this gets executed right away without showing the edit prompt for each commit.

This can be followed up with a force push git push -f on the current branch to modify remote commits.

More from this blog

Adarsh Konchady's Blog

23 posts