I am sure there is no way to automatically do this. Remember that the “git rewrite wizard” can also return you to a shell that needs to resolve merge conflicts, so if you want to write a script to automate all of this, you need to take this into account.
You can pretty easily track which branches need updating. Hmm, for any branch, "git rev-list branch..master" will output if the branch is not updated in the top (i.e., it just ends on top). Thus, you need to go through all the local heads, except that the wizard for creating the report (nb "git show-branch" will do this approximately):
git for-each-ref 'refs/heads/*' | \ while read rev type ref; do branch=$(expr "$ref" : 'refs/heads/\(.*\)' ) revs=$(git rev-list $rev..master) if [ -n "$revs" ]; then echo $branch needs update git diff --summary --shortstat -M -C -C $rev master fi done
So, if you felt brave, you could replace this "git diff" with something like "git checkout $ branch & git master basase" (or maybe just "git pull - -rebase" if you installed it ) I think you will need to check the existence of the ".git / rebase-apply" directory or check the index for unrelated files ("git ls-files -u") to check if we have remained waiting for the merge.
Of course, if there are no conflicts, then it’s easy ... it creates something that also works when it’s not easy, that the problem is: p
And this does not necessarily apply to what happens if one of your branches is based on something else ... so I mentioned using git pull -rebase instead, because that would be rebase according to the branch configuration but not blindly from the master. Although the discovery is not based on the branch configuration ... perhaps it would be easiest to check each branch and make a "git pull" and allow the branch configuration to handle everything, including whether it needs to be reassembled or merged?
araqnid May 14, '09 at 23:19 2009-05-14 23:19
source share