pull/push from multiple remote locations

后端 未结 15 1259
傲寒
傲寒 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:24

    add an alias to global gitconfig(/home/user/.gitconfig) with below command.

    git config --global alias.pushall '!f(){ for var in $(git remote show); do echo "pushing to $var"; git push $var; done; }; f'
    

    Once you commit code, we say

    git push

    to push to origin by default. After above alias, we can say

    git pushall

    and code will be updated to all remotes including origin remote.

提交回复
热议问题