我試圖使用1.0版本的Bitbucket API的previously managed。從gitolite到bitbucket的腳本遷移
我需要從Gitolite遷移到Bitbucket,並且遇到與Bitbucket API v2.0有關的問題。
這裏是我的腳本代碼:
#!/bin/bash
# Usage: ./bitbucket-migrate.sh repos.txt
#
# repos.txt should have one repository per line.
echo "Reading $1"
while read line
do
repo=$line
echo "###"
echo "Cloning a bare copy of $repo"
git clone --bare [email protected]:$repo
echo "Waiting for clone completion"
sleep 45;
cd $repo.git
echo "Creating repo in Bitbucket"
curl -X POST -v -u [email protected]:password -H "Content-Type: application/json" \ https://api.bitbucket.org/2.0/repositories/teamname/$repo \ -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks"}'
echo "Pushing local mirror to bitbucket"
git push --mirror [email protected]:teamname/$repo.git
echo "Waiting for push completion"
sleep 45;
cd ..
echo "Removing $repo.git"
rm -rf "$repo.git"
echo "Waiting 10 seconds"
echo "###"
sleep 10;
done < $1
exit
此時腳本成功創建一個空的回購協議,而是試圖鏡子推到位桶時失敗。
爲了避免副本花費一段時間,我投入了幾次延長的睡眠,但我不相信它們會以這種方式產生效果。
這裏是收到錯誤回:
$ git push --mirror [email protected]:teamname/$repo.git
conq: not a git repository.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我需要做的鏡子推作爲第二API調用?那個電話會是什麼樣子?我有點迷失在這裏。
謝謝!
如果沒有更好的答案,那麼自學者就是這樣。 [http://stackoverflow.com/help/badges/14/self-learner] –