git cherry-pick 从其他分支检出指定的commit到当前分支
http://think-like-a-git.net/sections/rebase-from-the-ground-up/cherry-picking-explained.html
Git's own online help has a great, if characteristically terse, description of what the command does:
Given one or more existing commits, apply the change each one introduces, recording a new commit for each.
I've already mentioned (back on the page about garbage collection) that a Git commit's ID is a hash of both its contents and its history. So, even if you have two commits that introduce the exact same change, if they point to different parent commits, they'll have different IDs.
What git cherry-pick does, basically, is take a commit from somewhere else, and "play it back" wherever you are right now. Because this introduces the same change with a different parent, Git builds a new commit with a different ID.
Let's go back to this example from the reachability section:

If you were at node H in this graph, and you typed git cherry-pick E (yes, you'd actually type part or all of the SHA for the commit, but for simplicity's sake, I'll just use the labels that are already here), you'd wind up with a copy of commit E—let's call it "E prime" or E'—that pointed to H as its parent, like so:

Or, if you typed something like git cherry-pick C D E, you'd wind up with this when you were done:

The important thing to notice here is that Git has copied changes made in one place, and replayed them somewhere else.
Here's a quick slideshow that steps through the process:
原文有一个展示的系列图,想看的,可以去看原文
通过tortoisegit来操作cherry-pick
http://stackoverflow.com/questions/9415534/cherry-pick-using-tortoisegit

Cherry Pick可能遇到的问题
如果操作的commit是一次合并记录的话,此次的commit是有2个父节点的,需要用户指明,cherry-pick哪一个父节点。这样做,会丢失掉这次合并的记录。
我的处理方法是,直接忽略这次的commit,不进行cherrypick
The way a cherry-pick works is by taking the diff a changeset represents (the difference between the working tree at that point and the working tree of its parent), and applying it to your current branch.
So, if a commit has two or more parents, it also represents two or more diffs - which one should be applied?
You're trying to cherry pick fd9f578, which was a merge with two parents. So you need to tell the cherry-pick command which one against which the diff should be calculated, by using the -m option. For example, git cherry-pick -m 1 fd9f578 to use parent 1 as the base.
I can't say for sure for your particular situation, but using git merge instead of git cherry-pick is generally advisable. When you cherry-pick a merge commit, it collapses all the changes made in the parent you didn't specify to -m into that one commit. You lose all their history, and glom together all their diffs. Your call.
cherry pick遇到冲突的时候【使用tortoisegit】
tortoisegit正在进行的cherry-pick会停止下来,需要手动处理冲突文件,然后标记为已解决。记得要自己填写commit message,记录下是怎么处理冲突的。然后再点击commit
之后cherry pick会继续执行

不要经常使用cherry-pick
===2015年09月26日更新===
坑爹了,之前遇到的问题,cherry pick的commit如果是个合并记录的话,现在不想跳过
The way a cherry-pick works is by taking the diff a changeset represents (the difference between the working tree at that point and the working tree of its parent), and applying it to your current branch.
So, if a commit has two or more parents, it also represents two or more diffs - which one should be applied?
You're trying to cherry pick fd9f578, which was a merge with two parents. So you need to tell the cherry-pick command which one against which the diff should be calculated, by using the -m option.
For example, git cherry-pick -m 1 fd9f578 to use parent 1 as the base.
I can't say for sure for your particular situation, but using git merge instead of git cherry-pick is generally advisable.
When you cherry-pick a merge commit, it collapses all the changes made in the parent you didn't specify to -m into that one commit.
You lose all their history, and glom together all their diffs. Your call.
会出现提示:
$ git cherry-pick -m 2 fa14668b19899a92b5a4db254af90b730d4bf4ba
On branch chucklu_master
Your branch and 'chucklu/master' have diverged,
and have 19 and 70 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
You are currently cherry-picking commit fa14668.
nothing to commit, working directory clean
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:
git commit --allow-empty
Otherwise, please use 'git reset'
上面的分析,因为cherrypick的结果,没有任何改变,是没有意义的
http://stackoverflow.com/questions/14096244/why-is-git-cherrypick-saying-nothing-to-commit
It's exactly what it says: the changes you're trying to cherry-pick are already wholly contained in the branch you're on. I.e. the result of the cherry-pick is no changes. You can create an empty commit with the --allow-empty flag to indicate that you attempted to cherry-pick, but there were no changes to pull in.
git cherry-pick 从其他分支检出指定的commit到当前分支的更多相关文章
- Git如何检出指定目录或文件
系统版本:Window 10,Git 版本:2.7.1 对于大型 Git 仓库,每次执行 Git 命令,都需要经过漫长的等待,特别是要经常执行的 git status 命令.下面是一个例子... 从 ...
- GIT上面有的分支,本地却无法检出,也看不到该分支
正常情况在gitlib上面可以看到代码里面有develop的分支 然而本地在查看所有分支的时候却报错 #查看所有的分支 git branch -a 这种情况是没有更新远程分支的索引,所以这样是看不到的 ...
- Git sparse-checkout 检出指定目录或文件
根据网上资料整理而来,git 1.7版本后支持的sparse checkout特性,可以指定需要checkout的目录或者文件. # 设置允许git克隆子目录 git config core.spar ...
- Git学习之Git检出
================================================ HEAD 的重置即检出 ======================================= ...
- git 检出项目部分目录(稀疏检出)
git clone 会把整个项目都clone下来,对于大项目git status比较慢,每次pull时候也拉取一些无关的代码或者文件:git可以实现像svn一样检出部分目录 步骤: git clone ...
- git之rebase、merge和cherry pick的区别(面试常问)
git flow图例镇楼 merge 这个简单,初学者常用.比如主分支是Dev,最新版本是01.然后小明基于此,搞了个feature 分支A,业务:打酱油.然后在上面多次提交,完成功能迭代开发,如A1 ...
- git 版本检出checkout的方法笔记
想检出指定版本,比如回退版本,将代码检出到老代码 git checkout 版本号 git reflog git checkout 标签名 1.git log 查看版本信息,复制版本号,执行git ...
- 12.Git分支-推送(push)、跟踪分支、拉取(pull)、删除远程分支
1.推送 本地的分支并不会自动与远程仓库同步,你可以显示的向远程仓库推送你的分支.例如你在本地创建了一个dev分支,你想其他的人和你一样在dev之下进行工作,可以使用 git push <rem ...
- 版本控制git之三-多人协作 变基 推送 拉取 删除远程分支
版本控制git之三-多人协作 wangfeng7399已关注0人评论350人阅读2019-02-20 21:33:08 如果你想获得一份已经存在了的 Git 仓库的拷贝,比如说,你想为某个开源 ...
随机推荐
- Eclipse - 添加 PyDev 插件
1. 安装PyDev插件 启用Eclipse.在Help菜单中,选择Install New Software···, 然后点击Add按钮.在Location中输入:http://pydev.org/u ...
- Go语言学习资料汇总
网站: Go语言官网(访问)(中文镜像) Go语言中文网(访问) Go编译器(访问) Go语言中国社区(访问) golanghome(访问) GoLang中国(访问) Gopher Academic( ...
- Java-hibernate的Hello World
hibernate 是对jdbc进行轻量级封装的 orm 框架,充当项目的持久层. 要使用 hibernate首先就需要继续配置, 引包:下载hibernate然后加入jar包 同时引入mysql ...
- SQL学习:主键,外键,主键表,外键表,数据库的表与表之间的关系;
在数据库的学习中,对于一个表的主键和外键的认识是非常重要的. 主键:在一个表中,能唯一的表示一个事物(或者一条记录)的字段,我们称之为主键 注意: 主键的设置可以不只是用一个字段,也可以用若干个字段的 ...
- JS常用的7中跨域方式总结
javascript跨域有两种情况: 1.基于同一父域的子域之间,如:a.c.com和b.c.com 2.基于不同的父域之间,如:www.a.com和www.b.com 3.端口的不同,如:ww ...
- LCS最长公共子序列HDU1159
最近一直在学习算法,基本上都是在学习动态规划以及字符串.当然,两者交集最经典之一则是LCS问题. 首先LCS的问题基本上就是在字符串a,b之间找到最长的公共子序列,比如 YAOLONGBLOG 和 Y ...
- PHP程序开发人员要掌握的知识
文件目录处理函数包80%以上的函数的功能的灵活运用. 日期时间函数中的80%以上的函数的功能的灵活运用 数学函数库中的100%的内容. 网络库中的60%以上的内容,对各个函数的功能比较熟悉. 字符串处 ...
- 读书笔记之 - javascript 设计模式 - 观察者模式
在事件驱动的环境中,比如浏览器这种持续寻求用户关注的环境中,观察者模式是一种管理人与其任务(确切的讲,是对象及其行为和状态之间的关系)之间的关系的得力工具.用javascript的话来讲,这种模式的实 ...
- 笔记一:Python的PyDev插件在eclipse上面安装(新的插件地址 location)
注:部分内容参考网上的,若有侵权,请作者联系我,马上进行删改 安装PyDev: 首先需要去Eclipse官网下载:http://www.eclipse.org/,Eclipse需要JDK支持,如果Ec ...
- float浮动引起的ul高度崩溃与overflow的关系
今天遇到的问题真的让人不得不吐槽,因为一个很小的问题,花费了半天的时间来才解决这个问题.一直认为自己对Html与Css了解应该算蛮不错的,但是今天遇到的事情让我不得不反省自己的学习心态上的错误 ...