コードはかなり単純です。ウィンドウコマンドプロンプトを開き、calling()関数を実行するだけです。それは私がgit repoにプッシュするのに役立つ基本的なgitコマンドを持っています。私はsshとリモートrepoを設定しました。Python Git Bash CMDスクリプト
リンク:https://github.com/vivekpatani/git-script-gitter
私は、日付を変更することができますが、私はgitのにそれを押すと、それは私ではなく、私が犯し1を押した上で、現在の日付が表示されます。
ことが9日前と11日前、私は約束として、それは実際に同じ日付を表示したいコミット示しコミット一覧。
def calling():
#Simply opening command prompt in Windows
subprocess.call("git --version")
subprocess.call("git status")
subprocess.call("git add .")
subprocess.call("git commit -am \"Changing Things\" --date=\"Sat, 26 Mar 2016 18:46:44 -0800\"")
subprocess.call("git push origin master")
#To stop from cmd closing automatically
temp = input("Enter to close:")
def main():
calling()
if __name__ == "__main__":
main()
周囲を見回した後、私は、著者日付とコミット日付を一緒に変更する必要があることを読みましたか?誰かが私を助けてくれますか?
EDIT 1: 私はWindows OSで作業しています。
Git Bashを実行すると動作しますが、何とかそれをPythonに変換するだけです。
git --version
git status
git add .
GIT_AUTHOR_DATE='Fri Mar 25 19:32:10 2016 -0800' GIT_COMMITTER_DATE='Fri Mar 25 19:32:10 2016 -0800' git commit -am "Hello Laney"
git push origin master
EDIT 2:ソリューション
def calling(git_date):
subprocess.call("git --version")
subprocess.call("git status")
subprocess.call("git add .")
#The next statement is important as updates/adds new GitCommiterDate in environment making it the current commit date.
os.environ["GIT_COMMITTER_DATE"] = 'Fri Mar 25 19:32:10 2016 -0800'
#The date in commit command only changes author date.
subprocess.call("git commit -am \"Changing Things\" --date=\"Fri Mar 25 19:32:10 2016 -0800\"")
subprocess.call("git push origin master")
ありがとうございます。しかし、os.environを印刷すると、GIT_COMMITTER_DATEが見つかりません。また、行には構文の問題があります。あなたは私を導くことができますか? –
@VivekPatani目標は、環境変数にその変数を追加するのではなく、その変数を追加することです。 – VonC
@VivekPataniまた、二重引用符がありませんでした。 – VonC