对Git中的多个分支提交更改 [英] Commit a change to more than one branch in Git

查看:385
本文介绍了对Git中的多个分支提交更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

典型的使用场景:

我有master,branch_foo和branch_bar。所有都是最新的。现在,我做了一个git checkout master并开始修复错误。



可以说修复是在所有分支处于相同状态的跟踪文件上 - 即。在修复之前,来自每个分支的文件的差异不会导致差异。



有没有办法将此修复提交到所有分支?

解决方案

我期待 git cherry-pick 是你想要的。



将修复提交到第一个分支后,可以使用 git cherry-pick 将其合并到每个其他分支中。



这个相关的SO问题可能是有趣的:
Git&在多个分支上工作


Typical usage scenario:

I have master, branch_foo and branch_bar. All are up to date. Now, I do a "git checkout master" and work on a bug fix.

Lets say that fix was on a tracked file that is in the same state on all branches - ie. before the fix, a diff of the file from each branch results in no differences.

Is there a way to commit this fix to all branches?

解决方案

I expect git cherry-pick is what you want.

After committing the fix to the first branch, you can use git cherry-pick to merge it into each of the other branches.

This related question on SO may be of interest: Git & Working on multiple branches

这篇关于对Git中的多个分支提交更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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