I am trying to use GitPython to write Python scripts, which I can use to simplify my daily tasks, as I manage many branches.
I am also completely new to Python when it comes to writing complex scripts.
This is the API I used: GitPython API Document
I want to write it to GitPython, which simply does the following and parses the part that shows what the remote HEAD branch indicates. In other words, I want to basically get remotes/origin/HEAD
$ git branch -a master * branch_to_remove remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/testing
I look through an API document many times, at first itβs hard for me to understand the Python format of these API documents, and I could not find anything useful for this except remote_head in class git.refs.reference.Reference(repo, path, check_path=True)
But I donβt even know how to call / initialize it.
Here is what I had so far, and you can say what I'm trying to do is simply reset to the "no branch" state and delete the current branch on which I am on:
import git from git import * repo = git.Repo("/some/path/testing") repo.git.branch() [some code to get the remotes/origin/HEAD, set it to remoteHeadBranch ] repo.git.checkout(remoteHeadBranch)
Any help is much appreciated!
Thanks.
git python gitpython
xbeta
source share