git - Shell:Git 存储库创建脚本不向上游推送远程
问题描述
下面我有一个没有推送它的 shell 脚本,它在上游创建了远程分支。
我在本地测试了脚本,发现确实正在创建分支,但是一旦脚本到达该行,它似乎就中断了git push -u origin master
如果有人能指出我做错了什么,将不胜感激。
#!/bin/sh
set +x
localPath=$HOME/repos
token=""
instance=https://gitlab.####.com/api/v4
namespace_id=2 #This is the Flag group on our Gitlab instance.
# On first use, prompt user to input the Gitlab Private API token. Then, store it for future uses as token.txt.
if [ -f token.txt ]
then
read token < token.txt
else
read -p "Please input your Gitlab Private API Token from your user profile (https://gitlab.####.com/profile/account): " token
echo $token > token.txt
$token < token.txt
fi
for eachRepoName
do
#Local Work
mkdir -p $localPath
mkdir -p $localPath/$eachRepoName
cp Master-Ignore-List.txt $localPath/$eachRepoName/.gitignore
cd $localPath/$eachRepoName/
echo "pre-git"
git init
touch README.md
git add README.md .gitignore
echo "about to commit"
git commit -m "First Commit"
#End Local Work
curl -w "%{http_code}\n" --header "PRIVATE-TOKEN: $token" -X POST "$instance/projects?name=$eachRepoName&namespace_id=$namespace_id"
git remote add origin https://gitlab.####.com/flag/$eachRepoName.git
git push -u origin master
git checkout -b development
git push -u origin development
git remote set-head origin master
git branch -a
done
解决方案
推荐阅读
- css - Vaadin14 login-form css selector for shadow-root
- java - 避免 setRequestedOrientation 延迟
- python - 重塑一个长数组
- tooltip - Bootstrap 5 + Vue3:如何在卸载之前删除所有工具提示实例?
- sql - 存储过程清理
- testing - 测试咖啡馆未重定向到外部站点
- scala - java.lang.NoClassDefFoundError: scala/collection/convert/DecorateAsScala 但 pom.xml 中的 scala-library 使用 swagger 和 JBoss servlet
- python - 我试图从具有 100 个结果限制的 Api 获取数据,但是在使用时间戳更进一步时遇到问题
- c# - 使用 c#,为什么字母 r 和 b 被解释为标签文本中的 HTML 中断,我该如何阻止它?
- javascript - 如何通过 ajax 发布到烧瓶并更新 SQLAlchemy 数据库来删除事件 FullCalendar?