• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

git cherry: Find commits that have yet to be applied upstream

by admin

The git cherry command in Git allows you to find commits that exist in one branch but have not been applied upstream, meaning they have not been merged or cherry-picked into another branch. It helps identify commits that are unique to a branch and have not been incorporated into the main branch or any other branch.

Here’s an elaboration on its usage and functionality:

When you use git cherry, you specify two branches: the upstream branch and the branch you want to compare. Git will then analyze the commit history between these branches and identify any commits that are present in the branch being compared (HEAD) but are missing in the upstream branch.

Here are a few key points to understand about git cherry:

  • Comparing Branches: git cherry compares the commit history between two branches. The branch being compared is typically the current branch (HEAD), and the upstream branch is specified as an argument.
  • Identifying Unique Commits: Git will analyze the commit history and identify the commits that are unique to the branch being compared (HEAD). These are the commits that have not been applied upstream and are not present in the upstream branch.
  • Output Format: The output of git cherry consists of commit hashes prefixed with a + or – sign. Commits prefixed with + indicate that they are unique to the branch being compared (HEAD), while commits prefixed with – indicate that they are present in both branches.
  • Applying Commits: After using git cherry to identify the unique commits, you can choose to incorporate them into the upstream branch using tools like git cherry-pick or git merge.

By running git cherry, you can get a quick overview of the commits that are yet to be applied upstream. This can be useful when you want to determine which commits need to be incorporated into another branch or when you want to track the progress of commits that have not been merged yet.

It’s important to note that git cherry only compares the commit history between two branches and does not automatically apply or merge the identified commits. You still need to use other Git commands, such as git cherry-pick or git merge, to incorporate the identified commits into the desired branch.

git cherry Command Examples

1. Show commits (and their messages) with equivalent commits upstream:

# git cherry -v

2. Specify a different upstream and topic branch:

# git cherry origin topic

3. Limit commits to those within a given limit:

# git cherry origin topic base

Filed Under: Linux

Some more articles you might also be interested in …

  1. ifrename: command not found
  2. install-tl Command Examples
  3. mocp: command not found
  4. fping: A more powerful ping which can ping multiple hosts
  5. grub-script-check: command not found
  6. localectl: command not found
  7. pkill Command Examples in Linux
  8. apt: command not found
  9. crontab error : “You (user) are not allowed to access to (crontab) because of pam configuration.”
  10. bluetoothd Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright