git樱桃选择一个承诺到另一个分支 [英] git cherry picking one commit to another branch

查看:108
本文介绍了git樱桃选择一个承诺到另一个分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发工作环境时,我们为每个功能或修复工作创建了一个分支,然后合并到QA进行测试。

有助于获得包含特定进程的调试步骤的console.logs的存储。但我只希望它是我工作副本中的文件子集。



因此,我正在考虑创建另一个分支用于本地使用提交,稍后将使用它。其中没有必要引用特定的票。



所以问题是,我如何在这个有用的项目分支中进行特定的提交,并将其应用到另一个科?对不起,如果我在这里使用的术语樱桃选择不正确。我使用sourcetree,但也可以使用命令行。

解决方案

有几种方法可以实现它(您必须在你想应用提交的分支上),

你可以创建你想要的提交补丁然后应用它

  git format-patch< commit sha1> 
git apply< patch path>

或者您确实可以挑选您想要的提交

  git cherry-pick< commit sha1> 


In developing for a work enviornment, we create a branch for each feature or fix we work on, and then merge to QA for testing.

Occasionally I find it's helpful to have a stash which contains console.logs' of debugging steps for a specific process. But I want to only have that be a subset of files in my working copy.

So, I am considering creating another branch for local use with commits which will be used later. Which don't reference a specific ticket necessarily.

So the question is, how can I take a specific commit in this "useful items" branch, and apply it to another branch? I'm sorry if I'm using the term cherry pick incorrectly here. I use sourcetree but am able to use command line for this also.

解决方案

there are several ways to achieve it (you have to be on the branch you want to apply the commit to),

you can create a patch of the commit you want then apply it

git format-patch <commit sha1> 
git apply <patch path>

or you can indeed cherry-pick the commit you want

git cherry-pick <commit sha1>

这篇关于git樱桃选择一个承诺到另一个分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆