2014-02-17 34 views
1

我正在嘗試獲取一些與我們同步的GIT存儲庫。隨着這些項目的進出,我決定創建一個單獨的腳本,我使用CronTab調用以預製腳本。正在同步GIT:refspec主機不匹配任何

我確實嘗試過這種方法,但它確實有效,但是與其他版本庫不同。

我的bash腳本:

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:[email protected][email protected]/scm/git/$REPO 
       git push origin master 
       popd 
     fi 
done 

一切順利完美,直到git的一部分。這克隆的作品。遠程重命名的作品遠程添加工作,但是混帳推給我一個錯誤:

error: src refspec master does not match any. 
error: failed to push some refs to 'http:http://APIUser:[email protected][email protected]/scm/git/EXTERNAL-REPO-Projectx' 

此錯誤意味着主不存在外部吧?但據我所知,它確實存在。我也讀過: Git push existing repo to a new and different remote repo server?Push origin master error on new repository

這個我做了一些更多的研究混帳之後,我想通了的外部使用命名發展和主要只是初始提交的分支。

我在做一些巨大的Git錯誤?我該如何解決這個問題,或者有更好的方法來同步兩個gits?

在我忘記之前: 我試圖添加所有,我嘗試過之前提交。

因此我讀過: src refspec master does not match any when pushing commits in gitgit: error: src refspec master does not match any

+2

它是否適合你,如果你用手工做? –

+0

@МалъСкрылевъ其中一個回購確實有效,所有其他回報。沒有,並給出這個錯誤。 – Stolas

+0

在推送之前嘗試做拉,在其他人上 –

回答

0

問題已解決,外部方沒有一個主分支。只有一個發展分支。

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:[email protected][email protected]/scm/git/$REPO 
       git push origin develop 
       popd 
     fi 
done 
相關問題