LoginSignup
13
4

More than 5 years have passed since last update.

GitHubで自動Commit/Pushをしてくれるシェルスクリプト(Mac)

Last updated at Posted at 2018-05-30

開発目的

 LaTexで書いたレポートをGitHubのリポジトリに追加していると,コミットするのがめんどくさかったので,コミット,プッシュを自動でしてくれるシェルスクリプトを作成しました.

仕様

 起動時にコミットし,それ以降1時間間隔でコミット,3時間間隔でプッシュを行います.この間隔はシェルスクリプトを編集して変えることができます.プログラムの最初に指定するGitのパスを指定してください.

ソースコード

GitHubにあるので部分的に機能の説明
コミット
プッシュの場合はgitコマンドを変更

auto_commit.sh
path="/Users/"
clear
cd $path
echo ""
echo $path
git add .
git commit -m 'auto commit'
echo ""
echo "wait 1 hour"
echo ""

プログレスバー

auto_commit.sh
:auto_commit.sh
A=0
while [ $A -le $C ]
do
  B=""
  for i in `seq 1 $C`
  do
  if [ $A -eq $i ]
  then
  B="$B>"
  else
  if [ $i -le $A ]
  then
    B="$B-"
    else
    B="$B "
    fi
  fi
done

実行結果


On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

wait 1 hour

 until commit...  [--------->                              ] 25 %

GitHub

git clone https://github.com/reo11/Git_Auto_Commit.git

参考

定期的に自動でコミットさせるスクリプト
https://qiita.com/narikei/items/b4e1c035c778d4eb2fc9
シェル:プログレスバーの作り方
https://qiita.com/toyohama/items/aa093bf0352ea623c670

13
4
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
13
4