【发布时间】:2016-02-19 18:52:54
【问题描述】:
我想克隆一个存储库,更改一个文件并将这些更改的文件推回原始分支。 我可以用
克隆回购repo = pygit2.clone_repository(repo_url, local_dir, checkout_branch="test_it")
但是我现在需要做什么才能将更改推送到遥控器?我只想提交一个特定文件的更改,即使更改了更多文件。
希望有人可以帮助我。 TIA
【问题讨论】:
我想克隆一个存储库,更改一个文件并将这些更改的文件推回原始分支。 我可以用
克隆回购repo = pygit2.clone_repository(repo_url, local_dir, checkout_branch="test_it")
但是我现在需要做什么才能将更改推送到遥控器?我只想提交一个特定文件的更改,即使更改了更多文件。
希望有人可以帮助我。 TIA
【问题讨论】:
仅第一阶段file_path:
# stage 'file_path'
index = repository.index
index.add(file_path)
index.write()
然后做一个提交:
# commit data
reference='refs/HEAD'
message = '...some commit message...'
tree = index.write_tree()
author = pygit2.Signature(user_name, user_mail)
commiter = pygit2.Signature(user_name, user_mail)
oid = repository.create_commit(reference, author, commiter, message, tree, [repository.head.get_object().hex])
最后按Unable to ssh push in pygit2中的描述推送回购
【讨论】: