I am trying to check out a git branch,generate files using python code and then push the changes to the branch using GitPython library
Below is the code used
repo = git.Repo(build_agent_artifact_directory)
branch_name = source_branch_name.split('/')[-1]
if branch_name in repo.branches:
repo.git.checkout(branch_name)
**Python code to generate files and add it to the remote location**
repo.git.add('--all')
repo.index.commit("pushing generated files")
origin = repo.remote(name='origin')
origin.push()
Getting below error when script is executed.
git.exc.GitCommandError: Cmd(‘git’) failed due to: exit code(128)
cmdline: git push –porcelain origin
stderr: ‘fatal: You are not currently on a branch.’