LoginSignup
0
0

More than 3 years have passed since last update.

GitHubでフォーク(Fork)した複数のrepositoryを同期(sync)するスクリプト

Posted at

前提条件

スクリプトファイルを保存したディレクトリのサブディレクトリとしてクローン(git clone)したディレクトリが存在している。

リポジトリのリスト

以下の内容のテキストファイルを githubrepos.txt で保存する。

Aerial master
Pi_Servo_Hat master
RPi_Cam_Web_Interface master
RPi_PanTilt_Camera_Kit master
tensorflow/docs-l10n master
covid19 development
covid19-saitama development
aiyprojects-raspbian aiyprojects

同期スクリプト

以下の内容の bash スクリプトファイルを sync_upstream.sh で保存する。

#!/usr/bin/env bash

sync_upstream()
{
  cd $1
  pwd
  # echo $2
  git fetch upstream
  git merge upstream/$2
  git push
  cd -
}

while read repo default
do
  sync_upstream $repo $default
done < githubrepos.txt

実行属性の付加

次のコマンドを実行し sync_upstream.sh に実行属性を付ける。

chmod u+x sync_upstream.sh

同期の実行

次のコマンドを実行すれば、同期が開始する。

./sync_upstream.sh
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