Create new repo on Bitbucket from Git Bash terminal?

前端 未结 7 1481
别那么骄傲
别那么骄傲 2020-12-22 19:56

Is it possible to create a new repository in Bitbucket by using command line Git? I have tried the following:

git clone --bare https://username@bitbucket.org         


        
7条回答
  •  既然无缘
    2020-12-22 20:29

    I've made a slight modification to @pztrick above script. This new script should work the same, but it uses the newer 2.0 API:

    function startbitbucket {
        echo 'Username?'
        read username
        echo 'Password?'
        read -s password  # -s flag hides password text
        echo 'Repo name?'
        read reponame
    
        curl -X POST -v -u $username:$password  -H "Content-Type: application/json" \
      https://api.bitbucket.org/2.0/repositories/$username/$reponame \
      -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }'
    
        git remote add origin git@bitbucket.org:$username/$reponame.git
        git push -u origin --all
        git push -u origin --tags
    }
    

    You can place this in your .bashrc or .bash_aliases file (just like the original script).

    Note that it will also create this as a private repo. You can change "is_private": "true" to "is_private": "false" to make it a public repo.

提交回复
热议问题