Shell:Git Repo创建脚本未向上游推送远程

时间:2019-04-11 19:44:13

标签: git shell

下面我有一个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

0 个答案:

没有答案
相关问题