pull/push from multiple remote locations

后端 未结 15 1245
傲寒
傲寒 2020-11-21 10:17

The short: is there a way to have a git repo push to and pull from a list of remote repos (rather than a single \"origin\")?

The long:

15条回答
  •  醉话见心
    2020-11-21 10:37

    I took the liberty to expand the answer from nona-urbiz; just add this to your ~/.bashrc:

    git-pullall () { for RMT in $(git remote); do git pull -v $RMT $1; done; }    
    alias git-pullall=git-pullall
    
    git-pushall () { for RMT in $(git remote); do git push -v $RMT $1; done; }
    alias git-pushall=git-pushall
    

    Usage:

    git-pullall master
    
    git-pushall master ## or
    git-pushall
    

    If you do not provide any branch argument for git-pullall then the pull from non-default remotes will fail; left this behavior as it is, since it's analogous to git.

提交回复
热议问题