John Robins
John Robins

Reputation: 1547

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

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?

Upvotes: 2

Views: 450

Answers (1)

jub0bs
jub0bs

Reputation: 66204

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.)

Upvotes: 3

Related Questions