xxxxxxxxxx
// Check current branch
git branch --show-current
xxxxxxxxxx
//all branch and current branch
git branch
//current branch
git branch --show-current
xxxxxxxxxx
import subprocess
def get_current_branch():
command = 'git rev-parse --abbrev-ref HEAD'
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
current_branch = output.decode().strip()
return current_branch
# Example usage
current_branch = get_current_branch()
print(current_branch)