Fetch and Merge into all Branches at once from Upstream Repository

泄露秘密 提交于 2019-12-11 10:08:35

问题


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 is the original repository).

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.

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


回答1:


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.



来源:https://stackoverflow.com/questions/49033529/fetch-and-merge-into-all-branches-at-once-from-upstream-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!