How to pull from the remote using dulwich?

2024/9/20 9:44:39

How to do something like git pull in python dulwich library.

Answer

I haven't used dulwich, but from these doc's, possibly something like:

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"]

At this point, it didn't load the files, but I could do "git checkout" from the local path, and it updated the files.

Also, saw these:

  • https://lists.launchpad.net/dulwich-users/msg00118.html
  • Programmatically `git checkout .` with dulwich
https://en.xdnf.cn/q/72513.html

Related Q&A

convert python programme to windows executable

i m trying to create windows executable from python program which has GUI . i m using following scriptfrom distutils.core import setup import py2exesetup(console=[gui.py]) it gives following errorWarni…

Must explicitly set engine if not passing in buffer or path for io in Panda

When running the following Python Panda code:xl = pd.ExcelFile(dataFileUrl)sheets = xl.sheet_namesdata = xl.parse(sheets[0])colheaders = list(data)I receive the ValueError:Must ex…

How to access the keys or values of Python GDB Value

I have a struct in GDB and want to run a script which examines this struct. In Python GDB you can easily access the struct via(gdb) python mystruct = gdb.parse_and_eval("mystruct")Now I got t…

How can I fire a Traits static event notification on a List?

I am working through the traits presentation from PyCon 2010. At about 2:30:45 the presenter starts covering trait event notifications, which allow (among other things) the ability to automatically ca…

Calculate moving average in numpy array with NaNs

I am trying to calculate the moving average in a large numpy array that contains NaNs. Currently I am using:import numpy as npdef moving_average(a,n=5):ret = np.cumsum(a,dtype=float)ret[n:] = ret[n:]-r…

Python: numpy.insert NaN value

Im trying to insert NaN values to specific indices of a numpy array. I keep getting this error:TypeError: Cannot cast array data from dtype(float64) to dtype(int64) according to the rule safeWhen tryin…

Identify external workbook links using openpyxl

I am trying to identify all cells that contain external workbook references, using openpyxl in Python 3.4. But I am failing. My first try consisted of:def find_external_value(cell): # identifies an e…

3D-Stacked 2D histograms

I have a bunch of 2D histograms (square 2D numpy arrays) that I want to stack in 3D like so:(Image from: Cardenas, Alfredo E., et al. "Unassisted transport of N-acetyl-L-tryptophanamide through me…

Python and mySQLdb error: OperationalError: (1054, Unknown column in where clause)

Hey all, Im getting an error OperationalError: (1054, "Unknown column XX in where clause")Where XX is the value of CLASS in the following codeconn = MySQLdb.connect(host = "localhost&quo…

Best Python GIS library? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, argum…