pygit2 icon indicating copy to clipboard operation
pygit2 copied to clipboard

Cannot fetch unless a remote is defined

Open basak opened this issue 4 years ago • 2 comments

Hi,

Thank you for pygit2! I'm using it extensively for git tooling in Ubuntu, but occasionally I find some corner where a feature doesn't exist and I have to resort to calling a git subprocess.

The git CLI allows me to use git fetch without having a remote defined. I can just specify a URL. I can't find any documentation on this in pygit2 though. It looks like I have to define a remote, with a name, first. Since I don't necessarily own the repository, this requires an ugly workaround because I have to be concerned about name collisions, crashing without having removed a temporary remote, etc.

Any chance of adding API functionality to fetch (and presumably) push against remotes with just a URL and no mandatory repository configuration please?

basak avatar Jan 14 '21 14:01 basak

I need this feature too.

ancieg avatar Feb 19 '25 08:02 ancieg

Seems that the following code do what I need:

remote = repo.remotes.create_anonymous("URL")
remote.fetch()

ancieg avatar Feb 19 '25 11:02 ancieg