LoginSignup
0
0

More than 3 years have passed since last update.

【Git】複数のリモートリポジトリに一括でpushしたい

Last updated at Posted at 2021-01-17

やりたいこと

ローカルの変更を

  • github
  • heroku

のリモートリポジトリに一括でpushしたい。

無題の図形描画.png

今回やってみた方法

こちらの記事を参考にしました 

git remote

でリモートリポジトリ名一覧を取得出来るので、
パイプを使ってxargsに渡し、各リモートリポジトリ名ごとにコマンドを作成します。

git remote | xargs -I reponame git push reponame main 
# -I reponame: 変数reponameを任意の場所で展開する

今回の環境では

$ git push heroku main
$ git push origin main

が順に実行されることになります

おまけ

エイリアス設定するとより楽になると思います

git config --global alias.pushall '!git remote | xargs -I reponame git push reponame main'

追記

githubにpushすると自動でherokuにデプロイしてくれる設定がありました...
初めからこれ使えばよかったですね
https://devcenter.heroku.com/ja/articles/github-integration

お読みいただきありがとうございました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0