Here is what I have in my ~/.bashrc
gitlify() { [ $# -eq 0 ] && return 1 repo_name=$1 username=smeagol token=01234567890 curl -H "Content-Type:application/json" https://gitlab.com/api/v4/projects?private_token=$token -d "{\"name\": \"$repo_name\"}" if [ $? -eq 0 ];then git init git add . git commit -m "first blood" git remote add origin git@gitlab.com:$username/$repo_name.git git push -u origin master else echo "error create gitlab repo $repo_name" fi}
You have to first have a token for your username. Once this bash function is in placed, you can use it by:
mkdir /tmp/firstbloodecho '#hello world'> /tmp/firstblood/README.mdcd /tmp/firstbloodgitlify fallenangel
This snippet is only for gitlab.com. I have another one that I named gitify for github.com.