从Git Bashterminal创build新的回购Bitbucket?
是否有可能通过使用命令行Git在Bitbucket中创build一个新的存储库? 我已经尝试了以下内容:
git clone --bare https://username@bitbucket.org/username/new_project.git 我得到这个消息:
克隆到裸仓库'new_project.git'…
致命的:https://username@bitbucket.org/username/new_project.git/info/refs找不到:你在服务器上运行git update-server-info?
如果不去networking应用程序,这将是很好的。
您可以使用Bitbucket REST API和cURL。 例如:
 curl --user login:pass https://api.bitbucket.org/1.0/repositories/ \ --data name=REPO_NAME 
 创build名为REPO_NAME新存储库。 
请参阅使用Bitbucket REST API以获取更多信息。
UPDATE
有关Bitbucket V2的具体信息,请参阅POST新的回购
 最近,我们可以使用bitbucket-cli 。 
 使用pip安装它 
 pip install bitbucket-cli 
然后使用创build一个回购
 bitbucket create --private --protocol ssh --scm git YOUR_REPO_NAME 
 请注意,这会创build一个私人的git --public ,如果您使用Mercurial,则可以使用--public公共访问权限和--scm hg 。 用户名参数可以通过--username YOUR_USER_NAME添加。 
这里是@ hannesr的脚本调整了一点,接受来自提示的input:
 # startbitbucket - creates remote bitbucket repo and adds it as git remote to cwd function startbitbucket { echo 'Username?' read username echo 'Password?' read -s password # -s flag hides password text echo 'Repo name?' read reponame curl --user $username:$password https://api.bitbucket.org/1.0/repositories/ --data name=$reponame --data is_private='true' git remote add origin git@bitbucket.org:$username/$reponame.git git push -u origin --all git push -u origin --tags } 
 你应该把它放在你的.bashrc或者.bash_aliases 。 
https://confluence.atlassian.com/bitbucket/repository-resource-423626331.html
 $ curl -X POST -v -u username:password -H "Content-Type: application/json" \ https://api.bitbucket.org/2.0/repositories/teamsinspace/new-repository4 \ -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }' 
我做了一个快速的shell脚本,负责在当前工作目录中创build一个本地git,执行“初始提交”,然后创buildbitbucket回购(使用Mareks curl方法),然后最后完成所需的所有操作承诺bitbucket。
(请注意,这只适用于私人回购协议,但如Patrick所述,这很容易改变)
像这样使用它:
 fillbucket <user> <password> <reponame> 
  git clone --bare不会在BitBucket上创build一个新的回购。 
 它复制您本地计算机上的现有BitBucket。 
 如果可能的话,它会使用BitBucket API 。 
 如此BitBucket API包装器项目所示, mkproject尚不可用。 
@hannester我分叉,并略微修改你的脚本。
您有不正确的远程URL(您在脚本中留下了您的用户名)。 修改它以在脚本文件中包含用户名和密码。
并改名为如何添加到path的说明:
使用cURL的最佳答案对我来说效果不佳,所以最后我用Python与Bitbucket-API一起完成了这个工作 。 以下是有关repository.create()调用的文档。
安装:
 pip install bitbucket-api 
python:
 >>> from bitbucket.bitbucket import Bitbucket >>> bb = Bitbucket(username, password) >>> bb.repository.create('awesome-repo', scm='git', private=True) (True, {u'scm': ...}) 
- 在Bitbucket Git存储库上链接最新的文件
- 在github,bitbucket等存储库网站上托pipe敏感数据有多安全?
- Mercurial Version Control在推送中显示错误
- Git Bitbucket:即使在上传我的公共SSH密钥后总是要求input密码
- 执行失败的应用程序:processDebugResources Android Studio
- 最简单的方法来重命名BitBucket上configuration的git项目
- Bitbucket:更新一个分叉来合并主repo的变化?
- 推后到bitbucket的Atlassian“标志”
- 如何从Android Studio将项目导入到bitbucket存储库?