2016-02-19 44 views
0

我想克隆一个存储库,更改文件并将这些已更改的文件推回到原始分支。 我可以克隆与如何使用pygit2推送到远程?

repo = pygit2.clone_repository(repo_url, local_dir, checkout_branch="test_it") 

但回购什么我现在需要做的推更改远程?我只想提交一个特定文件的更改,即使更多文件被更改。

希望有人能帮助我。 TIA

回答

0

第一阶段只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

描述