简体   繁体   中英

Can I add a file to one of my GitHub repositories without cloning / pulling from it?

假设您在GitHub上有一个远程存储库,并且想要向该存储库添加文件...可以在Git命令行中完成,而无需从该存储库中提取所有文件吗?

Suppose you have a remote repository on GitHub and you want to add a file to that repository... Can that be done at the Git command line, without pulling all the files from that repository?

The GitHub API now allows you to create, update, or delete a text file in one of your GitHub repositories at the command line , which creates a commit in the process; see this .

Alternatively, if you're not bent on using the command line, you can add a text file to one of your GitHub remote repo through the GitHub web interface ; see this .


However, adding a file (text or otherwise) to a remote repository is not possible with Git itself. You have no other choice but to

  1. clone the remote repo (or pull from it, if you already have a clone),
  2. add the file and create a commit in your local repo,
  3. push that commit to the remote.

(Of course, that's under the assumption that you have read and write access to that remote.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM