rnwolf / github-create-repo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

github-create-repo

Bash script for creating a github repository from the current directory inspired by the blog post by Eli Fatsi and developed into something more functional. Options are used to allow the repository name to be changed from the default current directory base name and a specific commit message to be specified. For diagnostic purposes the script can also list all repositories on your remote server.

The script uses the GitHub API v3, which uses HTTPS GET and POST requests to send and receive JSON data using cURL, as demonstrated in some of the examples in the API. Note that you need to have a github personal access token in order to use the API, which you can set up by following the steps on this article or going to the applications page on your your github profile page and creating a new personal access token with repo, user, and gist scopes (minimum). From this, you need to copy your token (before refreshing your page) and run git config --global github.token <token> with <token> replaced with your token string.

Alternatively, if you use or commit to multiple github accounts, with multiple ssh keys or with different account names (such as having separate public and enterprise accounts), you can specify a specific username and personal access token using command line parameters, as described in the man page. Enterprise github accounts use a different domain name, as they are not hosted on the standard github.com, and you can specify your domain name using the command line parameter (otherwise the remote repository will not be created). Note that this should be of the form yourdomain.com (where the default is api.github.com) and the api/v3/ will be added.

Note that if you do not already have a .gitignore and README.md in the current directory, the script will copy default .gitignore and README.md into the current directory before creating the github repository, as these are required.

Note that script has only be tested on Linux, and although cURL should work the same on Mac OS X and on Windows with Cygwin, there might be subtleties which have yet to be tested and discovered. Makefiles are provided for installation under these environments, which make github-create-repo.sh executable and globally accesible and makes .github-repo-defaults available for copying.

Install

Modify the Makefile.config to specify your home directory and run sudo make install.

Usage

github-create-repo -l
github-create-repo -v
github-create-repo -v -r "specific repository name" -m "specific commit message"

About


Languages

Language:Shell 87.2%Language:Makefile 12.8%