-
Notifications
You must be signed in to change notification settings - Fork 534
get all remote branches #601
Comments
You can do it using remote, err := repo.Remote("origin")
if err != nil {
// something with err
}
opts := &git.FetchOptions{
RefSpecs: []config.RefSpec{"refs/*:refs/*", "HEAD:refs/heads/HEAD"},
}
if err := remote.Fetch(opts); err != nil {
// something with err
} |
by get i meant retrieving the name and hash |
Hey @ankurmittal, I assume you are looking for something equivalent to The way we achieve this is by just starting a normal Some example code (with two functions copy-pasted directly from
Pull requests to add this porcelain functionality are definitely welcome! |
no i was looking for git branch -r, I just want local remote branches. I suppose i can get all references and check if they are remote but it seems like a overkill, not sure how git does it though |
As we have r.Branches function which returns all the branches can we have a branchtype so that is can return all local, remote or all the branches |
Ah, I understand now @ankurmittal. I think you have the right idea. Here is a simple example program that mimics
|
yeah that works thanks but the hash that i get for origin/HEAD is "0000000000000000000000000000000000000000", is this a bug? Should i open one? |
|
gotcha, thanks |
support feature to get all remote branches.
The text was updated successfully, but these errors were encountered: