linux shell脚本:通过API实现git仓库从gitee向gitlab的批量迁移(gitlab api)
生活随笔
收集整理的這篇文章主要介紹了
linux shell脚本:通过API实现git仓库从gitee向gitlab的批量迁移(gitlab api)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
gitee-url.txt.2:
git@gitee.com:proj1/javacode.git遷移腳本:
#!/bin/bash# gitlab訪問憑證 PRIVATE_TOKEN="*********" # gitlab api url gitlab_api_url=https://git.zhangxueliang.com/api/v4 # gitlab test_project的namespace_id namespace_id=40 # 目標遷移倉庫地址 gitlab_url=https://git.zhangxueliang.com/test_project # 記住git http倉庫賬號密碼 git config --global credential.helper cache for line in $(<gitee-url.txt.2); doline=$(echo $line | sed -e 's/\r//g');# eg:gotools.gittmp=${line#git@gitee.com:test_project/};if [[ "${line}" =~ ":xxx1" ]];thentmp=${line#git@gitee.com:xxx1/};fi# 倉庫名稱(不含.git) eg:gotoolsproject_name=${tmp%.git};# git clonegit clone --bare $line# 獲取namespace_id test_project=40# curl --request GET --header "PRIVATE-TOKEN:ThmpJQBf99nBYEo5N-wR" "https://git.zhangxueliang.com/api/v4/namespaces?per_page=50"# 在 gitlab 創建目標倉庫curl -k --request POST --header "PRIVATE-TOKEN:${PRIVATE_TOKEN}" --data "name=$project_name&namespace_id=$namespace_id" $gitlab_api_url/projects# git pushcd $tmpgit push --mirror $gitlab_url/$tmpcd ..rm -fr $tmp done總結
以上是生活随笔為你收集整理的linux shell脚本:通过API实现git仓库从gitee向gitlab的批量迁移(gitlab api)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux shell if判断字符串是
- 下一篇: reactjs redux chrome