从上游存储库一次获取并合并到所有分支 [英] Fetch and Merge into all Branches at once from Upstream Repository

查看:110
本文介绍了从上游存储库一次获取并合并到所有分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个github分支,已将其克隆到计算机上.在原始项目中,我已经打开了许多PR,每个PR都对应于它们自己的分支(我不使用master).有时,我偶尔会运行以下命令:

I have a github fork, which I have cloned onto my computer. On the original project, I have opened many PRs, and each of them correspond to their own branch (I don't use master). From time to time, I occasionally run the following command:

git fetch upstream && git merge upstream/master --no-edit

(upstream是原始存储库).

上面的命令用于更新我所在的当前分支.有没有一种方法可以一次对所有我的分支机构执行相同的操作?当前,要实现相同的行为,我必须git checkout到所有相应的分支,然后进行同步,我觉得这很繁琐.

The command above works for updating the current branch that I am on. Is there a way to do the same for all my branches at once? Currently, to achieve the same behavior, I have to git checkout to all of the respective branches, and then do the sync, which I find quite tedious.

(我对git还是很陌生,所以我很乐意在回答中进行大量解释)

(I am quite new to git, so I would appreciate a good amount of explanation in an answer)

推荐答案

无法使用非当前(未检出)分支进行合并或变基.合并/重新设置可能会有冲突,解决冲突的唯一方法是手动操作-因此需要签出分支.

There is no way to do merge or rebase with non-current (not checked out) branch. Merge/rebase could have conflicts and the only way to resolve them is manually — hence the requirement to checkout the branch.

如果所有分支都可以快速转发,则可以获取非当前分支.命令:

You can fetch non-current branches if all branches can be fast-forwarded. The command:

git fetch origin v1:v1 v2:v2

获取已命名的分支并将其快速转发.但是,如果分支不能快速转发,则合并的唯一方法是将其检出并合并.

fetches named branches and fast-forwards them. But if branch cannot be fast-forwarded the only way to merge is to check it out and merge.

这篇关于从上游存储库一次获取并合并到所有分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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