Skip to content

Get the output of "git ls-remote --heads origin" with GitPython #909

@inazir

Description

@inazir

Hello,

I have been trying to get the remote branches, to be more precise the output of the following command git ls-remote --heads origin. But I haven't been successful so far. I have tried the following methods in the mean time, which don't serve my purpose.

repo = git.Repo(my_git_path)

#method 1
current_branches = repo.git.branch('-a')

#method 2
current_branches = []
for ref in repo.git.branch('-r').split('\n'):
current_branches.append(ref)

Could anyone please help me with the issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions