要求:
问题:
Traceback (most recent call last): File "/home/amith/example.py", line 14, in <module> repo.index.add(folder_path) AttributeError: 'Repository' object has no attribute 'index'
我需要将此脚本集成到应该从配置文件接受凭据的Django应用程序中。
我尝试了以下链接,但对我来说没有任何作用。 -link1 -link2 -link3
from git import Repo
from github import Github
from pdb import set_trace as bp
repo_dir = '--------'
repo = Repo(repo_dir)
# using username and password
g = Github("-----", "------")
folder_path = '----------'
commit_message = 'Add New file'
repo.index.add(folder_path)
repo.index.commit(commit_message)
origin = repo.remote('origin')
origin.push()
因此,我收到此错误“ AttributeError:'Repository'对象没有属性'index'”。
完全错误-
Traceback (most recent call last):
File "/home/amith/example.py", line 14, in <module>
repo.index.add(folder_path)
AttributeError: 'Repository' object has no attribute 'index'