无法将本地文件提交到我的Github存储库

时间:2018-08-06 14:46:02

标签: python git github

我正在使用Raspbian和python 2.7.9。我克隆了我的repo(Test-git),并编写了以下代码来提交并将更改推送到文件(test_1.csv)到我的Github 回购。以下是我的代码:

from github import Github
import git

g = Github("22c34f753fc0e78c051ada0c622elwjwkjfkwhf")
for repo in g.get_user().get_repos():
    print(repo.name)

repo = git.Repo.init('/home/pi/Desktop/Test-git')

file = '/home/pi/Desktop/Test-git/test_1.csv' #path to file to push

repo.git.add(file) 

repo.git.commit(m = "commit message") 

repo.git.push('Test-git', 'HEAD:master') 

但是我收到以下错误:

  repo.git.commit(m = "commit message") 

  File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 551, in <lambda>
    return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 1010, in _call_process
    return self.execute(call, **exec_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/git/cmd.py", line 821, in execute
    raise GitCommandError(command, status, stderr_value, stdout_value)
GitCommandError: Cmd('git') failed due to: exit code(1)
  cmdline: git commit -m commit message
  stdout: 'On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
Changes not staged for commit:
    modified:   README.md

Untracked files:
    Doc/
    MA_token_2.py
    New.csv

no changes added to commit'

0 个答案:

没有答案