This question has already been answered:

The situation is such that I have a HOME server, with git and apache installed. The repository is stored on it and the hook is deployed to the web muzzle.

It is required to store its copy on bitbucket, github.

added to config

[remote "origin"] url = garmayev@server.dev:/var/git/*******.git fetch = +refs/heads/*:refs/remotes/origin/* [remote "bitbucket"] url = ssh://git@bitbucket.org/garmayev/*******.git fetch = +refs/heads/*:refs/remotes/origin/* 

Question: Is it possible to somehow automate push to two servers? Those. not to enter every time

git push origin

git push bitbucket

and enter once with git push and whiskers. At the moment, the last command of the rap will only push on origin.

Reported as a duplicate by members of aleksandr barakin , Community Spirit 21 Aug '17 at 1:23 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

    Do this

    1. git remote | xargs -L1 git push

      Get through the remote command a list of remote repositories, and call the push command for each

    2. To facilitate the introduction of such a long command, you can start alias .

      git config --global alias.pushall '!git remote | xargs -L1 git push'

      After that, instead of a long command, you can type

      git pushall

      "!" - the symbol is used if we call some external command that is not a git subcommand (in our case, this subcommand is a call to a git command). In this link at the very bottom of the page there is an explanation of the use of this symbol when creating aliases.

    • Explain to the ady what this command does !git remote | xargs -L1 git push !git remote | xargs -L1 git push ? - garmayev
    • git config --global alias.pushall '!git remote | xargs -L1 git push' git config --global alias.pushall '!git remote | xargs -L1 git push' At this command, only'! git was set in the notepad for the entire line, now it gives the message Expansion of alias 'pushall' failed; '~git remote | xargs -L1 git push' is not git command Expansion of alias 'pushall' failed; '~git remote | xargs -L1 git push' is not git command Expansion of alias 'pushall' failed; '~git remote | xargs -L1 git push' is not git command What to do? - garmayev
    • What was the way to look at the global config? After executing this command, pushall = !git remote | xargs -L1 git push pushall = !git remote | xargs -L1 git push . No edits in the notebook do not need. Do you register this line in the config? Character ! not missed? Judging by the error, missed. - Alexcei Shmakov
    • Thank you, figured out. In the process of editing this team highlighted quotes (I do not know why or why :)). Now everything works! Thank! - garmayev