2016-10-21 21:17:43 GMT

git bash function gitnew version 20161021-2045, now with BitBucket

See here for an introduction to this topic: [Git bash - Create remote repositories quickly on github and gitlab][1] Updated function to include bitbucket: ```` function gitnew() { # token path tokenPath='P:/' # name of remote remoteName='all' # github user user_github='username' # gitlab user user_gitlab='username' # bitbucket user user_bitbucket='username' ##### no config edits below this point # repo name repoName="$(basename "$PWD")" # check if path exists if [ ! -d "$tokenPath" ] # no path then echo 'error: token path not available' # path available else echo $'\nconfig: github\n--------------------' git remote add "$remoteName" 'git@github.com:'"$user_github"'/'"$repoName"'.git' echo $'\nconfig: gitlab\n--------------------' git remote set-url "$remoteName" --add 'git@gitlab.com:'"$user_gitlab"'/'"$repoName"'.git' echo $'\nconfig: bitbucket\n--------------------' git remote set-url "$remoteName" --add 'git@bitbucket.org:'"$user_bitbucket"'/'"$repoName"'.git' echo $'\nquerying github\n--------------------' curl \ -u "$user_github":"$(cat "$tokenPath"'github.token.txt')" \ 'https://api.github.com/user/repos' \ -d '{"name":"'"$repoName"'"}' echo $'\nquerying gitlab\n--------------------' curl \ -H 'PRIVATE-TOKEN: '"$(cat "$tokenPath"'gitlab.token.txt')" \ 'https://gitlab.com/api/v3/projects' \ --data-urlencode 'name='"$repoName" \ --data-urlencode 'public=true' echo $'\nquerying bitbucket\n--------------------' curl \ -X POST \ -H 'Content-Type: application/json' \ -u "$user_bitbucket":"$(cat "$tokenPath"'bitbucket.token.txt')" \ 'https://api.bitbucket.org/2.0/repositories/'"$user_bitbucket"'/'"$repoName" \ -d '{"scm":"git"}' fi } ```` [1]: http://spenibus.net/b/p/r/Git-bash-Create-remote-repositories-quickly-on-github-and-gitlab