All developers that use GIT as a way for version controlling should know how essential is it sometimes to push your commits to different remote repositories. whether for backing up or to submit your work to different destinations.
In this post, I will be explaining how to push your GIT repository to multiple remotes simultaneously with one git push command.
First, edit your local .git/config file to the following entry, make sure you use your URLs instead:
[remote "all"] # add URLs for all the GIT repositories you want to push to. url = email@example.com:myRepo.git url = firstname.lastname@example.org:myRepo.git url = git@anotherBackUp.com:myRepo.git
Once finished, and when you want to push your repository to the previously selected remotes, issue the following command:
git push all –all –dry-run -v
Note that this will push all local branches to all remotes mentioned earlier. you may want to use the following command to push only the working directory:
git push all --dry-run -v $ git push all --all --dry-run -v< Pushing to email@example.com:myRepo.git To firstname.lastname@example.org:myRepo.git * [new branch] datetime_massage_exp -> datetime_massage_exp * [new branch] jquery_attempt -> jquery_attempt Pushing to email@example.com:myRepo.git To firstname.lastname@example.org:myRepo.git * [new branch] datetime_massage_exp -> datetime_massage_exp< * [new branch] development -> development * [new branch] jquery_attempt -> jquery_attempt