Учитывая repo
из GitPython, как я могу создать новую локальную ветку, добавить несколько файлов и отправить ее на удаленный компьютер с помощью GitPython?
Чтобы создать repo
:
from git import *
curr_dir = os.path.dirname(os.path.realpath(__file__))
repo = Repo(curr_dir)
Пока я просто использую subprocess
:
def publish_changes_to_git(commit_msg):
curr_time = time.time()
ts = datetime.datetime.fromtimestamp(curr_time).strftime('%Y-%m-%d-%H-%M-%S')
branch_name = "auto-commit-{ts}".format(ts=ts)
subprocess.check_output(["git", "checkout", "-b", branch_name])
subprocess.check_output(["git", "add", SOME_PATH])
subprocess.check_output(
["git", "commit", "-m", "auto-git-commit: {msg}".format(msg=commit_msg)])