Is there any way to create a new folder in git repository using their API? Is it possible to do this with Trees API?
Asked
Active
Viewed 4,427 times
1 Answers
21
Yes, but you'd need to create a file in the directory because git only tracks directories with files in them.
Example:
Say we have a user called "foo" who has a repo called "bar". The repo has the following contents:
├── LICENSE
├── main.go
├── main_test.go
└── README.md
If we want to create a file in the examples
directory called example.go
, we would issue the following request:
PUT /repos/foo/bar/contents/examples/example.go
The template for the request to create new files is as follows:
PUT /repos/:owner/:repo/contents/:path
See http://developer.github.com/v3/repos/contents/#create-a-file

Zach Latta
- 3,251
- 5
- 26
- 40
-
Thanks a lot. Could you tell me if it is possible to rename git repo using API? – Nov 18 '13 at 10:44