[英]Updating multiple branches of a forked repository on Github
I have a forked github repository (call it repo-O and call my fork repo-F) which contains about 8 branches. 我有一个分叉的github存储库(称之为repo-O并调用我的fork repo-F),它包含大约8个分支。 Several (100s) commits have been made to repo-O from other contributors, and on multiple branches of repo-O.
已经有几个(100s)提交来自其他贡献者的repo-O,以及repo-O的多个分支。 I would now like to pull these changes into my forked repo (repo-F).
我现在想把这些变化拉进我的分叉回购(repo-F)。 I cant use the fork queue as there are about 3000 commits to pick through, and I would much rather do this from the command line.
我不能使用fork队列,因为有大约3000个提交可以通过,我宁愿从命令行执行此操作。
So.. I have cloned my repo, added repo-O as a remote (upstream) and fetched the changes, followed by merge origin/upstream... then a push back to repo-F. 所以..我克隆了我的仓库,将repo-O添加为远程(上游)并获取更改,然后合并origin / upstream ...然后推回repo-F。
This appears to have applied the changes to the master branch, but not to any other branch.... 这似乎已将更改应用于主分支,但不应用于任何其他分支....
How can I repeat the above process so that 'all' the branches are updated? 如何重复上述过程以便更新“所有”分支?
Thanks 谢谢
What you want to accomplish is "for each remote branch on repo-o, create the same branch pointing to repo-o's branch if I don't have it or pull information on the local branch from whatever is on the same branch on repo-o, and at the end push all these branches to my repo-f". 您要完成的是“对于repo-o上的每个远程分支,如果我没有它,则创建指向repo-o分支的相同分支,或者从repo-上同一分支上的任何内容中获取本地分支上的信息o,并最终将所有这些分支推送到我的repo-f“。
Assuming your remotes are really named repo-o
and repo-f
, I'd play with something like, in bash
: 假设你的遥控器真的名为
repo-o
和repo-f
,我会玩bash
:
for repo_o_branch in \
$(git branch -a|grep repo-o|perl -nle's,^\s*repo\-o/,,;print $_';
do
( \
( git checkout $repo_o_branch \
&& git pull --rebase repo-o $repo_o_branch) \
|| ( git checkout -b $repo_o_branch repo-o/$repo_o_branch ) \
) && git push repo-f $repo_o_branch;
done
For all "repo o branches" (shown by git branch -a
as " repo-o/branchname", without the "spaces and 'repo-o/'" part of it), 对于所有“repo o branches”(由
git branch -a
为“repo-o / branchname”,没有“spaces和'repo-o /'”部分),
git pull --rebase repo-o branchname
inside it, git pull --rebase repo-o branchname
, git checkout
fails (as you do not have that branch): checkout a new branch named after the repo-o's branch name and point it to repo-o's branchname. git checkout
失败(因为你没有那个分支):签出一个以repo-o的分支名称命名的新分支,并将其指向repo-o的branchname。 Season to taste; 品尝季节; best tried on a newly created git clone of
repo-f
with the remote repo-o
added to it, just in case things go wrong ;) 最好尝试一个新创建的
repo-f
git克隆,并添加远程repo-o
,以防万一出错;)
awk version with some merge treaks awk版本与一些合并的treaks
sync_all_branch () {
git fetch upstream
for upstream_branch in $( git branch -a |awk 'BEGIN {FS="/"} $2=="upstream" {print $3}' ) ;
do
if git checkout $upstream_branch
then
echo merge $upstream_branch
git merge -s recursive -Xours upstream/$upstream_branch
else
echo create $upstream_branch
git checkout -b $upstream_branch upstream/$upstream_branch
fi
done
git checkout master
git push --all
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.