Skip to content

Instantly share code, notes, and snippets.

@kaskichandrakant
Last active March 11, 2019 06:21
Show Gist options
  • Save kaskichandrakant/017e718f6f71267828d196fbbb95a0cf to your computer and use it in GitHub Desktop.
Save kaskichandrakant/017e718f6f71267828d196fbbb95a0cf to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$1" == "." ]; then
REPO_NAME=$(basename $PWD)
echo "creating $REPO_NAME repo on github"
git init .
curl -u "$(git config user.name)" https://api.github.com/user/repos -d '{"name":"'$REPO_NAME'"}'
elif [[ $# -gt 0 && "$1" != "-h" ]]; then
echo "creating $1 repo on github"
curl -u "$(git config user.name)" https://api.github.com/user/repos -d '{"name":"'$1'"}'
else
echo "Usage: gh_init [repo_name | . ]
. - To create repo with current directory name
repo_name - Creates repo with given name "
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment