Syncing GIT : refspec master does not match any

主宰稳场 提交于 2019-12-11 04:17:19

问题


I am trying to get a number of GIT repositories sync-ed with ours. As these projects come and go I decided to create one single script that I call with a CronTab in order to preform the script.

I did try this by hand and it did work, however with these other repositories it did not.

My Bash Script:

external_repos=( "OurName.projectx" "OurName.anotherproject" "OurName.thirdproject" "OurName.stackexchange" )

for i in "${external_repos[@]}"
do
        echo "Handling"  $i

        TEMP=`echo $i | cut -d "." -f 2`
        TEMP="${TEMP^}"
        REPO="EXTERNAL-REPO-$TEMP"

#       printf "Temp : %s\n" $TEMP
#       printf "Repo : %s\n" $REPO

        if [ -d "$i" ]; then
                pushd $i 
                git pull external_developer develop && git push origin master
                popd
        else
                git clone https://extern_u:$3cret@bitbucket.org/external/$i.git
                pushd $i
                git remote rename origin external_developer
                git remote add origin http://APIUser:P@s$w0rd@repo.ourdomain.com/scm/git/$REPO
                git push origin master
                popd
        fi
done

Everything goes perfectly, till the git part.. Cloning works. remote rename works remote add works but the git push gives me an error:

error: src refspec master does not match any.
error: failed to push some refs to 'http:http://APIUser:P@s$w0rd@repo.ourdomain.com/scm/git/EXTERNAL-REPO-Projectx' 

This error means that master does not exist external right? But as far as I know it does exist. Also I've read: Git push existing repo to a new and different remote repo server? and Push origin master error on new repository

After this I did some more research into git and I figured that the externals use a branch named develop and main is just for the initial commit.

Am I making some huge Git Error? How can I fix this issue or is there a better way to Sync two gits?

Before I forget: I tried to add all and I tried a commit before.

Thus I've read: src refspec master does not match any when pushing commits in git and git: error: src refspec master does not match any


回答1:


The issue is resolved, the external party did not have a master branch. Only a develop branch.

external_repos=( "OurName.projectx" "OurName.anotherproject" "OurName.thirdproject" "OurName.stackexchange" )

for i in "${external_repos[@]}"
do
        echo "Handling"  $i

        TEMP=`echo $i | cut -d "." -f 2`
        TEMP="${TEMP^}"
        REPO="EXTERNAL-REPO-$TEMP"

#       printf "Temp : %s\n" $TEMP
#       printf "Repo : %s\n" $REPO

        if [ -d "$i" ]; then
                pushd $i 
                git pull external_developer develop && git push origin develop
                popd
        else
                git clone https://extern_u:$3cret@bitbucket.org/external/$i.git
                pushd $i
                git remote rename origin external_developer
                git remote add origin http://APIUser:P@s$w0rd@repo.ourdomain.com/scm/git/$REPO
                git push origin develop
                popd
        fi
done


来源:https://stackoverflow.com/questions/21825601/syncing-git-refspec-master-does-not-match-any

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!