Is there any way to create a new folder in git repository using their API? Is it possible to do this with Trees API?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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