Closed
Labels
Description
I used GitHub Desktop to clone a repo with two branches from URL.
The following scripts only print the master branch.
repoRepo = git.Repo(os.getcwd())
print(repoRepo.heads)
If I switch to the other branch using GitHub Desktop, then it returns two heads. If I switch back to master again, it also shows two heads.

Is there a way to show all the heads at the beginning to avoid this manual work? For example, if I have 10 branches, i don't want to manually switch the branches 10 times to get them into Repo.heads.
Thanks.
Activity
Byron commentedon Nov 8, 2020
I believe what's at display here is a 'smart' feature implemented specifically to list local branches as well as remote branches. This explains why GitPython sees these as heads only after they have been checked out once, after all, this would create a local tracking branch.
In order to emulate this feature, one would have to look at remote branches as well.
I am closing this issue as Q&A, please feel free to keep posting here with follow ups as you see fit.