【发布时间】:2015-08-05 16:07:48
【问题描述】:
我有一个脚本可以从 GitHub 的命令行创建一个 git 存储库, 所以我的问题是当我尝试使用我的脚本在 GitLab 中创建一个新的仓库时,我的脚本不起作用!
repo_name=$1
dir_name=`basename $(pwd)`
if [ "$repo_name" = "" ]; then echo "Repo name (hit enter to use '$dir_name')?" read repo_name fi
if [ "$repo_name" = "" ]; then repo_name=$dir_name fi
username="xxxxxx" if [ "$username" = "" ]; then echo "Could not find username, run 'git config --global github.user <username>'" invalid_credentials=1 fi
token="xxxxxxxx" if [ "$token" = "" ]; then echo "Could not find token, run 'git config --global github.token <token>'" invalid_credentials=1 fi
echo -n "Creating Github repository '$repo_name' ..." curl -u "$username:$token" https://api.github.com/user/repos -d '{"name":"'$repo_name'"}' > /dev/null 2>&1 echo " done."
echo -n "Pushing local code to remote ..." git remote add origin git@github.com:$username/$repo_name.git > /dev/null 2>&1 git push -u origin master > /dev/null 2>&1 echo " done."
那么这个相当于什么
curl -u "$username:$token" https://api.github.com/user/repos -d '{"name":"'$repo_name'"}'
在 GitLab 中?
感谢您的阅读!
【问题讨论】:
-
您好!究竟什么不起作用,您遇到的具体错误是什么?