Quantcast
Viewing all articles
Browse latest Browse all 4

Answer by Philip Gaudreau for Using GitPython module to get remote HEAD branch

next(ref for ref in repo.remotes.origin.refs if ref.name == "origin/HEAD").ref.name

repo.remotes.origin.refs will give you a list of the remote branches. Filter on the one that is the HEAD and check towards what it points(ref<.name>).

You are now left with something like "origin/master" or "origin/main".


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>