ā¹ļø Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://phoenixnap.com/kb/git-cherry-pick |
| Last Crawled | 2026-04-08 00:19:05 (1 day ago) |
| First Indexed | 2023-10-02 15:02:29 (2 years ago) |
| HTTP Status Code | 200 |
| Meta Title | How to Cherry-Pick from Another Branch in Git | phoenixNAP KB |
| Meta Description | This step-by-step guide explains cherry-picking and shows how to cherry-pick a commit from one branch into another one in Git. |
| Meta Canonical | null |
| Boilerpipe Text | Topics:
Cherry-picking in Git is a useful operation that allows users to select and apply a single commit from one branch to another. It is an alternative to
git rebase and git merge
, which are used to apply multiple commits to another branch.
This tutorial will show how to cherry-pick a commit from another branch in Git.
Prerequisites
Git installed (follow our tutorials to
install Git on Ubuntu
,Ā
macOS
,Ā
Windows
,Ā
CentOS 7
, orĀ
CentOS 8
).
A
Git repository
.
A
separate branch
with multiple
commits
.
What Is Cherry-Picking in Git?
Cherry-picking in Git is a process of choosing and applying
specific commits
from one branch to another. Through cherry-picking, users can extract one or several commits from one branch's history and apply them as
new commits
on a different branch.
The process helps incorporate specific changes, such as bug fixes or features, without merging the entire source branch. Picking individual commits facilitates management and integrates changes granularly within a Git repository.
When to Use Git Cherry-Picking?
Use cherry-picking in Git to select specific changes from one branch and apply them to another without merging the entire branch. It is a great option for selectively incorporating bug fixes, features, or other changes from one branch into another.
While cherry-picking is a valuable tool for selective changes, consider the context of your project and its potential implications on commit history, collaboration, and code dependencies. If there are possible negative implications of cherry-picking, opt for alternative Git strategies like merging or rebasing.
The situations when you need to avoid using Git cherry-pick are:
When changes depend on a series of commits
. If the commit you want to pick depends on a series of commits in the source branch and cherry-picking them individually would break the intended functionality, merging or rebasing the entire branch is a better choice. Cherry-picking individual commits may result in the code not working as expected.
When it disrupts branch integrity.
Cherry-picking can disrupt the chronological order of commits in a branch's history. Avoid cherry-picking if it is crucial to preserve the exact branch history.
When it duplicates commits.
Cherry-picking can lead to duplicated commits if the same changes are cherry-picked into multiple branches. Doing so makes it hard to track changes and increases the risk of conflicts in the future.
When it causes merge conflicts.
Cherry-picking can introduce complex
merge conflicts
, especially when the same changes have occurred in the source and target branches. In that case, it is simpler to merge the branches instead.
How to Use Git Cherry-Picking?
To cherry-pick in Git, utilize the
git log
command to pinpoint the commit you want to cherry-pick. Then, cherry-pick the commit onto the target branch using the commit ID.
Follow the steps below:
1. Find the commit ID by running:
git log
For this tutorial, we will cherry-pick the commit
71277daebbb157f7018a73e482e2379d9efceb64
(new file) from the
master
branch. Take note of the commit ID you want to cherry-pick, as you will need it later.
2.
Switch to the branch
you want to cherry-pick the commit to. The syntax is:
git switch [branch-name]
We will cherry-pick the commit to a branch named
test-branch
:
3. After switching to the target branch, cherry-pick the commit using the commit ID you copied from the log. The syntax for cherry-picking is:
git cherry-pick [commit id]
We will run the following command to cherry-pick the commit mentioned earlier:
git cherry-pick 71277daebbb157f7018a73e482e2379d9efceb64
The command cherry-picks the specified commit from the
master
branch to the
test-branch
, adding a new commit in the branch history, as shown in the output of
git reflog
:
Conclusion
Git cherry-pick is a powerful and versatile tool that allows to selectively apply specific commits from one branch to another. However, make sure to use cherry-picking with caution and ensure that the changes you apply are appropriate in the context of the project to avoid conflicts and code inconsistencies.
Next, see how to
check out a file from another branch
or learn to
squash commits in Git
.
Was this article helpful?
Yes
No |
| Markdown | - [Call](https://phoenixnap.com/kb/git-cherry-pick)
- [Support](tel:1-855-330-1509)
- [Sales](tel:1-877-588-5918)
- [Login](https://phoenixnap.com/kb/git-cherry-pick)
- [Bare Metal Cloud](https://bmc.phoenixnap.com/)
- [Admin Hub](https://admin.phoenixnap.com/)
- [Partners](https://phoenixnap.com/partners)
- [COLOCATION](https://phoenixnap.com/colocation)
- [Colocation Premier Carrier Hotel](https://phoenixnap.com/colocation)
- [Data Center as a Service Solutions for Digital Transformation](https://phoenixnap.com/colocation/data-center-as-a-service)
- [Data Center as a Service Overview](https://phoenixnap.com/colocation/data-center-as-a-service)
- [Hardware as a Service Flexible Hardware Leasing](https://phoenixnap.com/colocation/hardware-as-a-service)
- [Bare Metal Cloud API-Driven Dedicated Servers](https://phoenixnap.com/bare-metal-cloud)
- [Object Storage S3 API Compatible Storage Service](https://phoenixnap.com/object-storage)
- [Meet-Me Room The Interconnectivity Hub](https://phoenixnap.com/colocation/meet-me-room)
- [Meet-Me Room Overview](https://phoenixnap.com/colocation/meet-me-room)
- [AWS Direct Connect Dedicated Link to Amazon Cloud](https://phoenixnap.com/colocation/aws-direct-connect)
- [Google Cloud Interconnect Private Connectivity to Google Cloud](https://phoenixnap.com/google-cloud-interconnect)
- [Megaport Cloud Router Simplified Multi-Cloud Connections](https://phoenixnap.com/offers/megaport-cloud-router)
- [All Carriers Global Interconnectivity Options](https://phoenixnap.com/colocation/all-carriers)
- [Schedule a Tour Guided Virtual Data Center Tour](https://phoenixnap.com/phoenix-data-center-virtual-tour)
- [Data Center Locations Global Data Center Footprint](https://phoenixnap.com/colocation/data-center-locations)
- [Data Center Locations Overview](https://phoenixnap.com/colocation/data-center-locations)
- [Phoenix, AZ The Largest Fiber Backbone in the U.S.](https://phoenixnap.com/colocation/phoenix)
- [Amsterdam, NL The Connectivity Hub of Europe](https://phoenixnap.com/colocation/amsterdam)
- [BARE METAL CLOUD](https://phoenixnap.com/bare-metal-cloud)
- [Platform API-Driven Dedicated Servers](https://phoenixnap.com/bare-metal-cloud)
- [Platform Overview](https://phoenixnap.com/bare-metal-cloud)
- [Infrastructure As Code DevOps Integrations](https://phoenixnap.com/bare-metal-cloud/infrastructure-as-code)
- [BMC vs. Dedicated Servers Choose the Best Option](https://phoenixnap.com/bare-metal-cloud-vs-dedicated-servers)
- [Pricing Instance pricing and cost estimation](https://phoenixnap.com/kb/git-cherry-pick)
- [Instance Pricing See All Configurations](https://phoenixnap.com/bare-metal-cloud/instances)
- [Pricing Calculator Get an Estimate](https://phoenixnap.com/cloud-pricing-calculator)
- [Network/IP Pricing Flexible IP Pricing](https://phoenixnap.com/bare-metal-cloud/ip-pricing)
- [Kubernetes Solutions Streamlined Kubernetes Management](https://phoenixnap.com/kb/git-cherry-pick)
- [Rancher Deployment One-Click Kubernetes Deployment](https://phoenixnap.com/bare-metal-cloud/rancher-deployment)
- [CPUs Next Gen Intel Processors](https://phoenixnap.com/kb/git-cherry-pick)
- [Xeon 6 6700-series with E-Cores Supercharge Cloud-Native Workloads](https://phoenixnap.com/bare-metal-cloud/intel-xeon-6-processors-with-e-cores)
- [Intel® Core⢠i9 14900K Ideal for Gaming, Streaming, and Content Creation](https://phoenixnap.com/bare-metal-cloud/intel-core-i9-14900k)
- [5th Gen Intel Xeon Scalable CPUs Boost Data-Intensive Workloads](https://phoenixnap.com/bare-metal-cloud/5th-gen-intel-xeon-scalable-processors)
- [HPE Ampere Altra Q80-30 HPEĀ® ProLiant RL300 as a service](https://phoenixnap.com/bare-metal-cloud/hpe-proliant-rl300)
- [Alliances Technology Partnerships](https://phoenixnap.com/bare-metal-cloud/technology-ecosystem)
- [Ecosystem Underlying Technologies](https://phoenixnap.com/bare-metal-cloud/technology-ecosystem)
- [NetrisOS VPC networking on bare metal](https://phoenixnap.com/bare-metal-cloud/netris)
- [Storage Options Flexible Storage Solutions](https://phoenixnap.com/kb/git-cherry-pick)
- [Object Storage S3-Compatible Storage Solution](https://phoenixnap.com/object-storage)
- [Network File Storage All-Flash Scale-Out Storage Resources](https://phoenixnap.com/network-file-storage)
- [GPU Servers For AI/ML and HPC workloads](https://phoenixnap.com/kb/git-cherry-pick)
- [Intel Max 1100 GPUs 1 system. 2 GPUs. Amazing performance.](https://phoenixnap.com/bare-metal-cloud/gpu-servers)
- [HYBRID CLOUD](https://phoenixnap.com/security/data-security-cloud)
- [Hybrid Cloud Overview](https://phoenixnap.com/cloud-services/hybrid-cloud-solutions)
- [Object Storage S3 Compatible Storage Solution](https://phoenixnap.com/object-storage)
- [Bare Metal Cloud API-Driven Dedicated Servers](https://phoenixnap.com/bare-metal-cloud)
- [Alternative Cloud Provider Overcome Public Cloud Limitations](https://phoenixnap.com/cloud-services/alternative-cloud-provider)
- [Backup Solutions Veeam-Powered Services](https://phoenixnap.com/backup-restore)
- [Disaster Recovery VMware, Veeam, Zerto](https://phoenixnap.com/disaster-recovery-as-a-service-draas)
- [Veeam Cloud Connect Backup and Replication](https://phoenixnap.com/backup-restore/veeam-cloud-connect)
- [Managed Backup for Microsoft 365 Veeam-Powered Service](https://phoenixnap.com/backup-restore/microsoft-365-backup)
- [NETWORK](https://phoenixnap.com/network)
- [Network Overview Global Network Footprint](https://phoenixnap.com/network)
- [Network Locations U.S., Europe, APAC, LATAM](https://phoenixnap.com/network/locations)
- [Speed Test Download Speed Test](https://phoenixnap.com/network/speed-test)
- [LEARN](https://phoenixnap.com/kb)
- [Blog IT Tips and Tricks](https://phoenixnap.com/blog/)
- [Resource Library Knowledge Resources](https://phoenixnap.com/company/resource-library)
- [Glossary IT Terms and Definitions](https://phoenixnap.com/glossary/)
- [Events Let's Meet\!](https://phoenixnap.com/company/it-events)
- [Newsroom Media Library](https://phoenixnap.com/company/press)
- [Developers Development Resources Portal](https://developers.phoenixnap.com/)
- [APIs Access Our Public APIs](https://developers.phoenixnap.com/apis)
- [GitHub Public Code Repositories](https://github.com/phoenixnap)
[Home](https://phoenixnap.com/) Ā» [KB](https://phoenixnap.com/kb/) Ā» [DevOps and Development](https://phoenixnap.com/kb/category/devops-and-development) Ā» How to Cherry-Pick from Another Branch in Git
# How to Cherry-Pick from Another Branch in Git


By
[Bosko Marijan](https://phoenixnap.com/kb/author/boskom)
Published:
October 2, 2023
Topics:
[git](https://phoenixnap.com/kb/tag/git)
Cherry-picking in Git is a useful operation that allows users to select and apply a single commit from one branch to another. It is an alternative to [git rebase and git merge](https://phoenixnap.com/kb/git-rebase-vs-merge), which are used to apply multiple commits to another branch.
**This tutorial will show how to cherry-pick a commit from another branch in Git.**


Prerequisites
- Git installed (follow our tutorials to [install Git on Ubuntu](https://phoenixnap.com/kb/how-to-install-git-on-ubuntu), [macOS](https://phoenixnap.com/kb/install-git-on-mac), [Windows](https://phoenixnap.com/kb/how-to-install-git-windows), [CentOS 7](https://phoenixnap.com/kb/how-to-install-git-on-centos-7), or [CentOS 8](https://phoenixnap.com/kb/how-to-install-git-centos-8)).
- A [Git repository](https://phoenixnap.com/kb/what-is-a-git-repository).
- A [separate branch](https://phoenixnap.com/kb/git-create-new-branch) with multiple [commits](https://phoenixnap.com/kb/how-git-works#ftoc-heading-3).
## What Is Cherry-Picking in Git?
Cherry-picking in Git is a process of choosing and applying **specific commits** from one branch to another. Through cherry-picking, users can extract one or several commits from one branch's history and apply them as [new commits](https://phoenixnap.com/kb/how-to-use-git#ftoc-heading-8) on a different branch.
The process helps incorporate specific changes, such as bug fixes or features, without merging the entire source branch. Picking individual commits facilitates management and integrates changes granularly within a Git repository.
## When to Use Git Cherry-Picking?
Use cherry-picking in Git to select specific changes from one branch and apply them to another without merging the entire branch. It is a great option for selectively incorporating bug fixes, features, or other changes from one branch into another.
While cherry-picking is a valuable tool for selective changes, consider the context of your project and its potential implications on commit history, collaboration, and code dependencies. If there are possible negative implications of cherry-picking, opt for alternative Git strategies like merging or rebasing.
The situations when you need to avoid using Git cherry-pick are:
- **When changes depend on a series of commits**. If the commit you want to pick depends on a series of commits in the source branch and cherry-picking them individually would break the intended functionality, merging or rebasing the entire branch is a better choice. Cherry-picking individual commits may result in the code not working as expected.
- **When it disrupts branch integrity.** Cherry-picking can disrupt the chronological order of commits in a branch's history. Avoid cherry-picking if it is crucial to preserve the exact branch history.
- **When it duplicates commits.** Cherry-picking can lead to duplicated commits if the same changes are cherry-picked into multiple branches. Doing so makes it hard to track changes and increases the risk of conflicts in the future.
- **When it causes merge conflicts.** Cherry-picking can introduce complex [merge conflicts](https://phoenixnap.com/kb/how-to-resolve-merge-conflicts-in-git), especially when the same changes have occurred in the source and target branches. In that case, it is simpler to merge the branches instead.
## How to Use Git Cherry-Picking?
To cherry-pick in Git, utilize the **`git log`** command to pinpoint the commit you want to cherry-pick. Then, cherry-pick the commit onto the target branch using the commit ID.
Follow the steps below:
1\. Find the commit ID by running:
```
git log
```


For this tutorial, we will cherry-pick the commit **`71277daebbb157f7018a73e482e2379d9efceb64`** (new file) from the **`master`** branch. Take note of the commit ID you want to cherry-pick, as you will need it later.
2\. [Switch to the branch](https://phoenixnap.com/kb/git-switch-branch) you want to cherry-pick the commit to. The syntax is:
```
git switch [branch-name]
```
We will cherry-pick the commit to a branch named **`test-branch`**:


3\. After switching to the target branch, cherry-pick the commit using the commit ID you copied from the log. The syntax for cherry-picking is:
```
git cherry-pick [commit id]
```
We will run the following command to cherry-pick the commit mentioned earlier:
```
git cherry-pick 71277daebbb157f7018a73e482e2379d9efceb64
```


The command cherry-picks the specified commit from the **`master`** branch to the **`test-branch`**, adding a new commit in the branch history, as shown in the output of **`git reflog`**:


**Note:** See how to [undo the last commit](https://phoenixnap.com/kb/git-revert-last-commit) using **`git revert`**.
Conclusion
Git cherry-pick is a powerful and versatile tool that allows to selectively apply specific commits from one branch to another. However, make sure to use cherry-picking with caution and ensure that the changes you apply are appropriate in the context of the project to avoid conflicts and code inconsistencies.
Next, see how to [check out a file from another branch](https://phoenixnap.com/kb/git-checkout-file-from-another-branch) or learn to [squash commits in Git](https://phoenixnap.com/kb/git-squash).
Was this article helpful?
YesNo
Contents
- [What Is Cherry-Picking in Git?](https://phoenixnap.com/kb/git-cherry-pick#What_Is_Cherry-Picking_in_Git)
- [When to Use Git Cherry-Picking?](https://phoenixnap.com/kb/git-cherry-pick#When_to_Use_Git_Cherry-Picking)
- [How to Use Git Cherry-Picking?](https://phoenixnap.com/kb/git-cherry-pick#How_to_Use_Git_Cherry-Picking)
Subscribe to our newsletter
[SUBSCRIBE](https://phoenixnap.com/developers-monthly-newsletter)
Next you should read
[](https://phoenixnap.com/kb/git-overwrite-local-branch-with-remote)
[DevOps and Development](https://phoenixnap.com/kb/category/devops-and-development) [SysAdmin](https://phoenixnap.com/kb/category/sysadmin)
[How to Overwrite Local Branch with Remote in Git](https://phoenixnap.com/kb/git-overwrite-local-branch-with-remote)
[](https://phoenixnap.com/kb/git-compare-two-branches)
[DevOps and Development](https://phoenixnap.com/kb/category/devops-and-development) [SysAdmin](https://phoenixnap.com/kb/category/sysadmin)
[How to Compare Two Git Branches](https://phoenixnap.com/kb/git-compare-two-branches)
[](https://phoenixnap.com/kb/git-change-commit-message)
[DevOps and Development](https://phoenixnap.com/kb/category/devops-and-development) [SysAdmin](https://phoenixnap.com/kb/category/sysadmin)
[How to Change Git Commit Message](https://phoenixnap.com/kb/git-change-commit-message)
[](https://phoenixnap.com/kb/git-fetch)
[DevOps and Development](https://phoenixnap.com/kb/category/devops-and-development)
[Git Fetch: Definition & Examples](https://phoenixnap.com/kb/git-fetch)
CONTACT US
[Get a Quote](https://phoenixnap.com/contact-us)
[Support (1-855-330-1509)](tel:1-855-330-1509)
[Sales (1-877-588-5918)](tel:1-877-588-5918)
- [Colocation](https://phoenixnap.com/colocation)
- [Phoenix](https://phoenixnap.com/colocation/phoenix)
- [Ashburn](https://phoenixnap.com/colocation/ashburn)
- [Amsterdam](https://phoenixnap.com/colocation/amsterdam)
- [Atlanta](https://phoenixnap.com/colocation/atlanta)
- [Belgrade](https://phoenixnap.com/colocation/belgrade)
- [Singapore](https://phoenixnap.com/colocation/singapore)
- [Shipping Instructions](https://phoenixnap.com/colocation/shipping-instructions)
RECENT POSTS
["Invalid Reference Format" Error in Docker: How to Fix](https://phoenixnap.com/kb/docker-invalid-reference-format)
[Python dict() Function Explained](https://phoenixnap.com/kb/python-dict)
[Ansible get\_url Module: Download Files from URL](https://phoenixnap.com/kb/ansible-get-url)
[Docker Desktop: Unexpected WSL Error](https://phoenixnap.com/kb/docker-desktop-unexpected-wsl-error)
[How to Check if a File Exists in Python](https://phoenixnap.com/kb/check-if-file-exist-python)
- [Servers](https://phoenixnap.com/servers/dedicated)
- [Bare Metal Cloud](https://phoenixnap.com/bare-metal-cloud)
- [Dedicated Servers](https://phoenixnap.com/servers/dedicated)
- [Database Servers](https://phoenixnap.com/servers/database)
- [Virtualization Servers](https://phoenixnap.com/servers/virtualization)
- [High Performance Computing (HPC) Servers](https://phoenixnap.com/servers/high-performance-computing-hpc)
- [Dedicated Streaming Servers](https://phoenixnap.com/servers/streaming)
- [Dedicated Game Servers](https://phoenixnap.com/servers/dedicated-game-servers)
- [Dedicated Storage Servers](https://phoenixnap.com/servers/storage)
- [SQL Server Hosting](https://phoenixnap.com/servers/sql-server-hosting)
- [Dedicated Servers in Amsterdam](https://phoenixnap.com/dedicated-servers-amsterdam-netherlands)
- [Cloud Servers in Europe](https://phoenixnap.com/cloud-services/cloud-servers-europe)
- [Big Memory Infrastructure](https://phoenixnap.com/bare-metal-cloud/big-memory-infrastructure)
- [Buy Now](https://admin.phoenixnap.com/wap-pncpadmin-shell/orderForm?bmbPath=/order-form?currencyCode=usd)
- [BMC portal](https://signup.bmc.phoenixnap.com/)
CLOUD SERVICES
- [Data Security Cloud](https://phoenixnap.com/security/data-security-cloud)
- [Managed Private Cloud](https://phoenixnap.com/private)
- [Object Storage](https://phoenixnap.com/object-storage)
- [Solutions](https://phoenixnap.com/infrastructure-solutions)
- [Disaster Recovery](https://phoenixnap.com/infrastructure-solutions/disaster-recovery-services)
- [Web Hosting Reseller](https://phoenixnap.com/reseller-hosting)
- [SaaS Hosting](https://phoenixnap.com/infrastructure-solutions/saas-hosting)
COMPLIANCE
- [HIPAA Ready Hosting](https://phoenixnap.com/compliance/hipaa-compliant-hosting)
- [PCI Compliant Hosting](https://phoenixnap.com/compliance/pci-compliant-hosting)
- [Privacy Center](https://phoenixnap.com/)
- [Do not sell or share my personal information](https://phoenixnap.com/)
NEEDS
- [Disaster Recovery Solutions](https://phoenixnap.com/infrastructure-solutions/disaster-recovery-services)
- [High Availability Solutions](https://phoenixnap.com/infrastructure-solutions/high-availability-solutions)
- [Cloud Evaluation](https://phoenixnap.com/offers/cloud-evaluation-demo)
INDUSTRIES
- [Web Hosting Providers](https://phoenixnap.com/reseller-hosting)
- [Legal](https://phoenixnap.com/infrastructure-solutions/legal-it)
- [MSPs & VARs](https://phoenixnap.com/infrastructure-solutions/it-partners)
- [Media Hosting](https://phoenixnap.com/infrastructure-solutions/media-hosting)
- [Online Gaming](https://phoenixnap.com/infrastructure-solutions/online-gaming)
- [SaaS Hosting Solutions](https://phoenixnap.com/infrastructure-solutions/saas-hosting)
- [Ecommerce Hosting Solutions](https://phoenixnap.com/infrastructure-solutions/ecommerce-hosting)
COMPANY
- [About phoenixNAP](https://phoenixnap.com/about)
- [IaaS Solutions](https://phoenixnap.com/company/iaas-provider)
- [Customer Experience](https://phoenixnap.com/company/customer-experience)
- [Platform](https://phoenixnap.com/cloud-services/platform)
- [Schedule Virtual Tour](https://phoenixnap.com/phoenix-data-center-virtual-tour)
- [Open Source Community](https://phoenixnap.com/company/open-source-community)
- [Resource Library](https://phoenixnap.com/company/resource-library)
- [Press](https://phoenixnap.com/company/press)
- [Events](https://phoenixnap.com/company/it-events)
- [Careers](https://techjobs.dev/jobs/)
- [Promotions](https://phoenixnap.com/promotions)
- [Contact Us](https://phoenixnap.com/contact-us)
- [Legal](https://phoenixnap.com/cs/legal/)
- [Privacy Policy](https://phoenixnap.com/infrastructure-solutions/legal-it/eu-u-s-data-privacy-framework-program-eu-u-s-dpf-compliant-privacy-policy)
- [Terms of Use](https://phoenixnap.com/cs/legal/aup.html)
- [DMCA](https://phoenixnap.com/cs/legal/dmca.html)
- [GDPR](https://phoenixnap.com/gdpr)
- [Sitemap](https://phoenixnap.com/sitemap)
- [Blog](https://phoenixnap.com/blog)
- [Resources](https://phoenixnap.com/company/resource-library)
- [Knowledge Base](https://phoenixnap.com/kb)
- [IT Glossary](https://phoenixnap.com/glossary)
- [GitHub](https://github.com/phoenixnap)
- [RFP Template](https://phoenixnap.com/company/it-resources/data-center-rfp-template)
Ā© 2025 phoenixNAP \| Global IT Services. All Rights Reserved. |
| Readable Markdown | 
Topics:
Cherry-picking in Git is a useful operation that allows users to select and apply a single commit from one branch to another. It is an alternative to [git rebase and git merge](https://phoenixnap.com/kb/git-rebase-vs-merge), which are used to apply multiple commits to another branch. **This tutorial will show how to cherry-pick a commit from another branch in Git.**  Prerequisites Git installed (follow our tutorials to [install Git on Ubuntu](https://phoenixnap.com/kb/how-to-install-git-on-ubuntu), [macOS](https://phoenixnap.com/kb/install-git-on-mac), [Windows](https://phoenixnap.com/kb/how-to-install-git-windows), [CentOS 7](https://phoenixnap.com/kb/how-to-install-git-on-centos-7), or [CentOS 8](https://phoenixnap.com/kb/how-to-install-git-centos-8)). A [Git repository](https://phoenixnap.com/kb/what-is-a-git-repository). A [separate branch](https://phoenixnap.com/kb/git-create-new-branch) with multiple [commits](https://phoenixnap.com/kb/how-git-works#ftoc-heading-3). What Is Cherry-Picking in Git? Cherry-picking in Git is a process of choosing and applying **specific commits** from one branch to another. Through cherry-picking, users can extract one or several commits from one branch's history and apply them as [new commits](https://phoenixnap.com/kb/how-to-use-git#ftoc-heading-8) on a different branch. The process helps incorporate specific changes, such as bug fixes or features, without merging the entire source branch. Picking individual commits facilitates management and integrates changes granularly within a Git repository. When to Use Git Cherry-Picking? Use cherry-picking in Git to select specific changes from one branch and apply them to another without merging the entire branch. It is a great option for selectively incorporating bug fixes, features, or other changes from one branch into another. While cherry-picking is a valuable tool for selective changes, consider the context of your project and its potential implications on commit history, collaboration, and code dependencies. If there are possible negative implications of cherry-picking, opt for alternative Git strategies like merging or rebasing. The situations when you need to avoid using Git cherry-pick are: **When changes depend on a series of commits**. If the commit you want to pick depends on a series of commits in the source branch and cherry-picking them individually would break the intended functionality, merging or rebasing the entire branch is a better choice. Cherry-picking individual commits may result in the code not working as expected. **When it disrupts branch integrity.** Cherry-picking can disrupt the chronological order of commits in a branch's history. Avoid cherry-picking if it is crucial to preserve the exact branch history. **When it duplicates commits.** Cherry-picking can lead to duplicated commits if the same changes are cherry-picked into multiple branches. Doing so makes it hard to track changes and increases the risk of conflicts in the future. **When it causes merge conflicts.** Cherry-picking can introduce complex [merge conflicts](https://phoenixnap.com/kb/how-to-resolve-merge-conflicts-in-git), especially when the same changes have occurred in the source and target branches. In that case, it is simpler to merge the branches instead. How to Use Git Cherry-Picking? To cherry-pick in Git, utilize the **`git log`** command to pinpoint the commit you want to cherry-pick. Then, cherry-pick the commit onto the target branch using the commit ID. Follow the steps below: 1\. Find the commit ID by running:  For this tutorial, we will cherry-pick the commit **`71277daebbb157f7018a73e482e2379d9efceb64`** (new file) from the **`master`** branch. Take note of the commit ID you want to cherry-pick, as you will need it later. 2\. [Switch to the branch](https://phoenixnap.com/kb/git-switch-branch) you want to cherry-pick the commit to. The syntax is: We will cherry-pick the commit to a branch named **`test-branch`**:  3\. After switching to the target branch, cherry-pick the commit using the commit ID you copied from the log. The syntax for cherry-picking is: We will run the following command to cherry-pick the commit mentioned earlier:  The command cherry-picks the specified commit from the **`master`** branch to the **`test-branch`**, adding a new commit in the branch history, as shown in the output of **`git reflog`**:  Conclusion Git cherry-pick is a powerful and versatile tool that allows to selectively apply specific commits from one branch to another. However, make sure to use cherry-picking with caution and ensure that the changes you apply are appropriate in the context of the project to avoid conflicts and code inconsistencies. Next, see how to [check out a file from another branch](https://phoenixnap.com/kb/git-checkout-file-from-another-branch) or learn to [squash commits in Git](https://phoenixnap.com/kb/git-squash). Was this article helpful? YesNo |
| Shard | 39 (laksa) |
| Root Hash | 8557101678125738839 |
| Unparsed URL | com,phoenixnap!/kb/git-cherry-pick s443 |