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

Laptop with some code on screen

I want to write my first embedded program. Where do I start?

The boom in the Internet of Things (IoT) commercial devices and hobbyist platforms like the Raspberry Pi and Arduino have created a lot of options, offering inexpensive platforms with easy to use development tools for creating embedded projects. You have a lot of options to choose from. An embedded development platform is typically a microcontroller chip mounted on a circuit board designed to show off its features. There are typically two types out there: there are inexpensive versions, sometimes called

Read More »
Medical device monitoring vitals

IEC-62304 Medical Device Software – Software Life Cycle Processes Primer – Part 1

IEC-62304 Software Lifecycle requires a lot of self-reflection to scrutinize and document your development processes. There is an endless pursuit of perfection when it comes to heavily regulated industries. How can you guarantee something will have zero defects? That’s a pretty hefty task. The regulatory approach for the medical device industry is process control. The concept essentially states that if you document how every step must be completed, and provide checks to show every step has been completed properly, you

Read More »
Operating room filled with medical devices

IEC-62304 Medical Device Software – Software Life Cycle Processes Primer – Part II

Part I provides some background to IEC-62304. Part II provides a slightly more in-depth look at some of the specifics. The IEC 62304 Medical Device Software – Software Lifecycle Processes looks into your development processes for creating and maintaining your software. The standard is available for purchase here. So what activities does the standard look at? Here are some of the major topics. For any given topic, there will be a lot more specifics. This will look at a few

Read More »