|
| 1 | +--- |
| 2 | +kind: change |
| 3 | +title: Initialize a repository when creating |
| 4 | +created_at: 2012-9-28 |
| 5 | +author_name: pengwynn |
| 6 | +--- |
| 7 | + |
| 8 | +Today we've made it easier to add commits to a repository via the GitHub API. |
| 9 | +Until now, you could [create a repository](/v3/repos/#create), but you would |
| 10 | +need to initialize it locally via your Git client before adding any commits via |
| 11 | +the API. |
| 12 | + |
| 13 | +Now you can optionally init a repository when it's created by sending `true` |
| 14 | +for the `auto_init` parameter: |
| 15 | + |
| 16 | +<preclass="terminal"> |
| 17 | +curl -i -u pengwynn \ |
| 18 | + -d '{"name": "create-repo-test", "auto_init": true}' \ |
| 19 | + https://api.github.com/user/repos |
| 20 | +</pre> |
| 21 | + |
| 22 | +The resulting repository will have a README stub and an initial commit. |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +### .gitignore templates |
| 27 | + |
| 28 | +Along with this change, you can set up your `.gitignore` template by passing |
| 29 | +the basename of any template in the [GitHub gitignore templates |
| 30 | +project](https://github.com/github/gitignore). |
| 31 | + |
| 32 | +<preclass="terminal"> |
| 33 | +curl -i -u pengwynn \ |
| 34 | + -d '{"name": "create-repo-test", "auto_init": true, \ |
| 35 | + "gitignore_template": "Haskell"}' \ |
| 36 | + https://api.github.com/user/repos |
| 37 | +</pre> |
| 38 | + |
| 39 | + |
| 40 | +As the [docs point out](/v3/repos/#create), the `gitignore_template` parameter |
| 41 | +is ignored if `auto_init` is not present and `true`. |
| 42 | + |
| 43 | +If you have any questions or feedback, drop us a line at |
| 44 | +[https://github.com/contact][c], [support@github.com][email], or |
| 45 | +[@GitHubAPI][twitter]. |
| 46 | + |
| 47 | +[twitter]: https://twitter.com/githubapi |
| 48 | +[email]: mailto:support@github.com |
| 49 | +[c]: https://github.com/c |
| 50 | + |