1

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:[email protected]/external/$i.git pushd $i git remote rename origin external_developer git remote add origin http://APIUser:P@[email protected]/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@[email protected]/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

4
  • 2
    does it work for you, if you do it by hands? Commented Feb 17, 2014 at 10:20
  • @МалъСкрылевъ One of the repos did work, all the other. Did not and give this error. Commented Feb 17, 2014 at 10:37
  • try to do pull before push, on others Commented Feb 17, 2014 at 10:55
  • @МалъСкрылевъ Same error. The pull results in a 'Already up-to-date.' Commented Feb 18, 2014 at 9:54

1 Answer 1

0

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:[email protected]/external/$i.git pushd $i git remote rename origin external_developer git remote add origin http://APIUser:P@[email protected]/scm/git/$REPO git push origin develop popd fi done 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.