Windows環境でプロンプト等を開いて毎回git push、pullコマンドをうつのが面倒だったので、それらのスクリプトをpythonで書いてみました。
以下のプログラムはgitで管理しているディレクトリの一番上で実行します。
実行環境
- python 3.6.5
- Git for Windows
Pull コマンド
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
# Push | |
os.system('git pull') |
Push コマンド
以下のプログラムを実行すると、その時点での時間"年:月:日-時:分:秒"でコミットして、Pushします。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
from datetime import datetime | |
# Commit comment | |
now = datetime.now() | |
comment = datetime.now().strftime("%Y/%m/%d-%H:%M:%S") | |
# Push | |
os.system('git add .') | |
os.system('git commit -m {}'.format(comment)) | |
os.system('git push') |
コメント