The Git Cherry-pick and Git Rebase Interactive Combo

Puzzle pieces on a light grey background

Version control is necessary, but using it well is an art. Today I am going to give an overview of two Git commands that I found helpful during software development, git cherry-pick and git rebase in interactive mode.

Git Cherry-pick

Software development is often a team game. To work within the planned schedule, each developer will implement features in their own feature branches. But sometimes there are changes that everyone wants! git cherry-pick is a Git command that lets the developer pick a commit and apply it to their branch. This command comes in handy when you want to use features implemented by other developers but your branch isn’t built off their branch or when you just need to make one change but don’t want all of their changes right now.

As an example, consider this scenario: an existing bug made it into the main branch. A developer solves it in their branch. They’re still working on their branch, but you’re done with yours. Instead of waiting for the fix to make it into the main branch or creating an entirely new branch just for the fix, you can “cherry-pick” the commit that fixes the bug into your branch.

# Check out the branch you are interested in cherry-picking from
% git checkout <interested-feature-branch>

# Look for the commit SHA of the commit you want to cherry-pick
# Note: Press enter/return to scroll down the list and press q to exit
% git log

# Check out your branch
% git checkout <your-feature-branch>

# Cherry-pick the commit to your branch
% git cherry-pick <commit-sha>

Git Rebase Interactive

While cherry-picking can be valuable, it can also cause duplicate commits and can lead to unnecessary code conflicts during pull requests. To avoid this, we can “squash” the commits or drop the duplicated commit before creating a pull request. We can achieve this by using git rebase in interactive mode. Unlike the standard git rebase that rebases all commits to the desired branch, you have control over your commit history with an interactive git rebase.

# Check out your branch
% git checkout <your-feature-branch>

# Rebase interactively on another branch, e.g. master
% git rebase -i <another-branch>
# You can also use % git rebase --interactive <another-branch>

git rebase -i will list the commits on the current branch in a vim editor. You can remove or squash commits here.

The following is an example after calling git rebase -i.

pick 7cb4839 Old commit 1
pick e616408 Duplicate commit
pick 79bd7a2 Old commit 2
pick fcaf152 fixup! Old commit 2
pick bdcd3db Add new feature

# Rebase 0462d8f..bdcd3db onto 0462d8f (1 command)
#
# Commands:
# p, pick &lt;commit> = use commit
# r, reword &lt;commit> = use commit, but edit the commit message
# e, edit &lt;commit> = use commit, but stop for amending
# s, squash &lt;commit> = use commit, but meld into previous commit
# f, fixup &lt;commit> = like "squash", but discard this commit's log message
# x, exec &lt;command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop &lt;commit> = remove commit
# l, label &lt;label> = label current HEAD with a name
# t, reset &lt;label> = reset HEAD to a label
# m, merge [-C &lt;commit> | -c &lt;commit>] &lt;label> [# &lt;oneline>]
# .       create a merge commit using the original merge commit's
# .       message (or the oneline, if no original merge commit was
# .       specified). Use -c &lt;commit> to reword the commit message.
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#

If you are new to vim, you can go to the duplicate commit line and press d twice.

“Squashing” keeps the work on a commit but adds the changes to the commit before it. If you want to squash the fixup! Old commit 2 commit to the Old commit 2 commit, you can put your cursor over squash in the comments and type yiw, then put it over to the pick before the fixup! Old commit 2 commit and replace it by typing viwp.

# VIM Definition
yiw = yank inner word (inner = the word your cursor is on)
viwp = visual + inner word + paste

Now, the pick turns into squash, as seen here:

pick 7cb4839 Old commit 1
pick 79bd7a2 Old commit 2
squash fcaf152 fixup! Old commit 2
pick bdcd3db Add new feature

When you are satisfied with the changes, press esc to make sure you are out of any mode and enter :wq to save and continue rebasing. If there are merge conflicts, resolve them, and then use git rebase –continue to finish the rebase. If you are in the middle of rebasing and regret making some changes, you can reset everything back to its original state by using git rebase –abort. Once you see the following message, you can now push the commits to your remote.

Successfully rebased and updated 
refs/heads/<your-feature-branch>.

Bonus: VSCode

If you are a VSCode user, the interactive rebase experience can be further improved by a VSCode extension called GitLens. Once the extension is installed, to enable the feature, open the command palette (for a MacBook user, enter command + shift + P), enter GitLens: Enable Interactive Rebase Editor, and press enter. Then, set up VSCode as the default editor for git, change directory to the repository, run git config –global -e, and add the following config key-value pair to the core section:

[core]
    ...
    editor = code --wait

Now, whenever you run git rebase -i <target-branch> from the terminal, VSCode will open an interactive rebase GUI page for you to make changes to the commits.

With these Git commands, your commit history will look clean and clear while working in a team.

What’s Next For Your Embedded Project?

Mastering Git commands like cherry-pick and rebase -i isn’t just about cleaner commits — it’s about building reliable firmware faster, with fewer surprises and less rework. At Dojo Five, we believe embedded teams deserve the same modern tools and workflows that app developers take for granted.

That’s why we built EmbedOps — to give embedded engineers a consistent, modern development environment that makes version control, CI/CD, and team collaboration seamless. If you want to streamline builds, reduce friction in your process, and ship smarter, sign up for free and see how EmbedOps can support your workflow.

Have a tricky firmware challenge or an upcoming project you’d like to talk through? Let’s chat. 

Let’s build better firmware, together.

Discover why Dojo Five EmbedOps is the embedded enterprise choice for build tool and test management.

Sign up to receive a free account to the EmbedOps platform and start building with confidence..

  • Connect a repo
  • Use Dev Containers with your Continuous Integration (CI) provider
  • Analyze memory usage
  • Integrate and visualize static analysis results
  • Perform Hardware-in-the-Loop (HIL) tests
  • Install the Command Line Interface for a developer-friendly experience

Subscribe to our Monthly Newsletter

Subscribe to our monthly newsletter for development insights delivered straight to your inbox.

Interested in learning more?

Best-in-class embedded firmware content, resources and best practices

Man sitting in front of three monitors

The Case for EmbedOps (Embedded DevOps)

From even before the first computer was working, the technology industry has been looking for the best way to write code. Today, as code “eats the world”, the types of things developers need to do is not limited to coding. There are managing releases and versions, managing development environments, testing, integrating, and so on. In the web, desktop, and mobile industries, tools have been created to automate and streamline the additional work as well as make good code easier to

Read More »
glasses on a laptop

Unit Tests: Benefits For Your Automatic Build

What are Unit Tests? Unit tests are functions written to test an isolated module in a codebase. Isolation allows for specific modules to be tested without interaction with the rest of the system. Unit tests are designed to test the top-level application program interface (API) by inducing controlled input to the module and monitoring the resulting behavior. Benefits of Automatic Unit Tests After unit tests have been created for a codebase, it only makes sense to get the most value

Read More »
The Role of Version Control in Modern Firmware Development

The Role of Version Control in Modern Firmware Development

Version control, also known as source control, is a tool that tracks and manages changes to files in a software project. It has been widely practiced by software teams to speed up software development. Source control platforms, such as GitHub and Bitbucket, securely host software code in a single location, allowing developers to pull it down from anywhere with an internet connection and start developing new features. Firmware development also adopts the same practices. This blog post discusses the crucial

Read More »