我有一个带有git存储库的项目,并且本地文件夹中的历史记录完整无缺。我想将此项目连同git repo一起上传到bitbucket服务器。但是我不想在bitbucket中手动创建存储库。我可以按照以下步骤在bitbucket中自动创建存储库吗?
git remote add origin https://User@bitbucket.ad.local/scm/proj1/repos1.git
(bitbucket server url without creating repos)
git clone C:\repos1.get https://User@bitbucket.ad.local/scm/proj1/repos1.git
(cloning the BB repo to my local)
unzip my project folder into this location
git add
git push -u origin master
这些是步骤。这些步骤会自动在BB中创建一个仓库吗?我知道使用API创建存储库。但是想知道这些“反向”步骤是否行得通。
答案 0 :(得分:0)
如果您不想手动创建它,请使用脚本进行创建:
# Create Project
curl -u <username>:<password> \
-X POST http://<bitbucketIP>:7990/rest/api/1.0/projects \
-H "Content-Type: application/json" \
-d @- << EOF
{ "key":"<project key>",
"name":"<project name>"
}
EOF
# Create repositories
curl -u <username>:<password> \
-X POST http://<bitbucketIP>:7990/rest/api/1.0/projects/<project name>/repos \
-H "Content-Type: application/json" \
-d @- << EOF
{ "slug": "<project name>",
"name": "<project name>",
"scmId": "git",
"project": {
"key": "<Project name from prevoius step>"
}
}
EOF