5
python dulwichライブラリでgit pull
のようにする方法。dulwichを使用してリモートから引き出す方法は?
python dulwichライブラリでgit pull
のようにする方法。dulwichを使用してリモートから引き出す方法は?
私はダルウィッチを使用していないが、何か多分、these doc'sから:この時点で
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"]
、それはファイルをロードしませんでしたが、私はローカルパスから「Gitのチェックアウト」を行うことができますそれを更新しました。
全例:
また、これらのを見ました。 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)
LOCAL_FOLDER、REMOTE_URL、USERNAME、PASSWORDをデータに置き換えます。
はい、fetch関数は '.git'ディレクトリの下にパックファイルをプルします。そして私はそれをマスターブランチにどのようにマージするのか分かりません。 – Determinant
fetch()は、repoと同じブランチにパックをインポートする必要があります。 do_commit()を使用してマスターブランチにマージすることは可能ですか? http://stackoverflow.com/questions/6904734/in-dulwich-how-do-i-commit-to-a-branch-instead-of-to-head –
私は恐れていません... – Determinant