3
我們正試圖自動提交遺留目錄上的更改,其中人們不想使用類似版本控制(嘆氣)的內容。自動提交存儲庫中的更改
我使用gitpython每天晚上提交這些更改:
repo = git.Repo(local_directory)
changed_files = [change.a_blob.path for change in repo.index.diff(None)]
if changed_files or repo.untracked_files:
if changed_files:
repo.git.add(update=True)
if repo.untracked_files:
repo.git.add(repo.untracked_files)
repo.git.commit(message='Auto committed')
repo.remotes.origin.push(repo.head)
有時提交失敗,「‘git的承諾--message =自動致力於’退出碼1返回」 - 我不能重現
有什麼我做錯了嗎?我讀過,也許我應該使用repo.index進行提交?
最好,克里斯托弗
感謝您的評論!所以用repo.remotes.origin.push(repo.head)推動仍然是一樣的? – Schinken
是的,'repo.remotes.origin.push'是正確的......雖然你可能能夠逃避不包括'repo.head' –