2012-08-15 26 views

Trả lời

5

tôi đã không sử dụng Dulwich, nhưng từ these doc's, có thể là một cái gì đó như:

from dulwich.repo import Repo 
from dulwich.client import HttpGitClient 
local = Repo.init("local", mkdir=True) 
client = HttpGitClient('http://github.com/adammorris/') 
remote_refs = client.fetch("history.js.git",local) 
local["HEAD"] = remote_refs["refs/heads/master"] 

Tại thời điểm này, nó không tải các tập tin, nhưng tôi có thể làm "git checkout" từ con đường địa phương và cập nhật tệp.

Ngoài ra, thấy những:

+0

Có, hàm tìm nạp sẽ kéo vào một tệp gói trong thư mục '.git'. Và tôi không biết cách kết hợp nó vào nhánh chính. – Determinant

+0

Có vẻ như hàm fetch() nên nhập gói vào cùng một chi nhánh làm repo. Có thể sử dụng do_commit() để kết hợp nó vào nhánh chính không? http://stackoverflow.com/questions/6904734/in-dulwich-how-do-i-commit-to-a-branch-instead-of-to-head –

+0

Tôi không sợ ... – Determinant

1

Full ví dụ. Hoạt động với Bitbucket.

from dulwich import index 
from dulwich.client import HttpGitClient 
from dulwich.repo import Repo 

local_repo = Repo.init(LOCAL_FOLDER, mkdir=True) 
remote_repo = HttpGitClient(REMOTE_URL, username=USERNAME, password=PASSWORD) 
remote_refs = remote_repo.fetch(REMOTE_URL, local_repo) 
local_repo[b"HEAD"] = remote_refs[b"refs/heads/master"] 

index_file = local_repo.index_path() 
tree = local_repo[b"HEAD"].tree 
index.build_index_from_tree(local_repo.path, index_file, local_repo.object_store, tree) 

Thay thế LOCAL_FOLDER, REMOTE_URL, USERNAME, PASSWORD bằng dữ liệu của bạn.

Các vấn đề liên quan