0

I'm trying to do something like repo.git.commit('-m', 'test commit', author='[email protected]') but instead of the author, I want to pass the --allow-empty to send a dummy commit to the repo. but the repo.git.commit() complains about the number of arguments I'm trying to pass. This is what I have so far:

from git import Repo
import os
from dotenv import load_dotenv

load_dotenv()

full_local_path = os.getenv('full_local_path')
username = os.getenv('username')
password = os.getenv('password')

remote = f"https://{username}:{password}@github.com:myRepo/myRepo.git"
Repo.clone_from('[email protected]:myRepo/myRepo.git', full_local_path)
Repo.git.commit('-m', 'empty commit', author='xxxxxxxxx')`
0

1 Answer 1

5

You're ignoring the return value from Repo.clone_from, which is the Repo object on which you'll operate in subsequent commands. You want something like:

>>> from git import Repo
>>> r = Repo.clone_from('https://github.com/octocat/Hello-World', 'hello-world')
>>> r.git.commit('-m', 'empty commit', '--allow-empty')
'[master 8d7508e] empty commit'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.