How do I push new files to GitHub?

后端 未结 6 879
独厮守ぢ
独厮守ぢ 2020-12-08 22:31

I created a new repository on github.com and then cloned it to my local machine with

git clone https://github.com/usrname/mathematics.git

I

6条回答
  •  [愿得一人]
    2020-12-08 22:59

    I tried to use the GitHub API to commit multiple files. This page for the Git Data API says that it should be "pretty simple". For the results of that investigation, see this answer.

    I recommend using something like GitPython:

    from git import Repo
    
    repo_dir = 'mathematics'
    repo = Repo(repo_dir)
    file_list = [
        'numerical_analysis/regression_analysis/simple_regression_analysis.py',
        'numerical_analysis/regression_analysis/simple_regression_analysis.png'
    ]
    commit_message = 'Add simple regression analysis'
    repo.index.add(file_list)
    repo.index.commit(commit_message)
    origin = repo.remote('origin')
    origin.push()
    

    Note: This version of the script was run in the parent directory of the repository.

提交回复
热议问题