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. Several (100s) commits have been made to repo-O from other contributors, and on multiple branches of repo-O. I would now like to pull these changes into my forked repo (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.

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.

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

Answers


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".

Assuming your remotes are really named repo-o and repo-f, I'd play with something like, in 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),

  • try checking out the branch and doing a git pull --rebase repo-o branchname inside it,
  • or, if the 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.
  • If any of the two above succeed, push the newly created or updated branch name to your repo-f.

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 ;)


Need Your Help

Windows Phone WebBrowser Control Not Rotating, Height Not 100%

c# windows-phone-7 browser

I'm building my first simple Windows Phone app. I'm having some trouble though.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.