2012-05-24 78 views
4

也許是一個重複的問題,儘管我試圖找出現有問題的答案但失敗。
無法將文件推送到新創建的git倉庫

我創建了一個混帳回購協議在服務器上使用命令:

mkdir gitrepo 
cd gitrepo 
git init 

然後從另一臺機器我試圖文件推送到該回購,但失敗了。

git init 
git clone [email protected]:~/gitrepo/.git 
cd gitrepo 
touch test 
git add test 
git commit -a 

現在使用,沒有錯誤發生。當我嘗試將更改推送到服務器時,發生以下錯誤:

>git push 
No refs in common and none specified; doing nothing. 
Perhaps you should specify a branch such as 'master'. 
fatal: The remote end hung up unexpectedly 
error: failed to push some refs to '[email protected]:~/gitrepo/.git' 

任何人都遇到過此問題嗎?

我發現了一個博客,可以很好地解釋非裸露和非裸露回購之間的區別。 http://www.bitflop.com/document/111 那些得到同樣問題的人可能會提到這一點。

+1

也許你應該指定一個分支,比如'master'。 – Emily

+0

我試過這個「git push master」,得到了「致命的:'master'似乎不是一個git倉庫。致命:遠程端意外掛斷」。目前我在主分支上 – cheng

回答

4

在第一臺機器上,您創建了非裸存儲庫或具有工作副本的存儲庫。推向非裸回購可以得到一點刺激,所以確保這實際上是你想要的。

在第二臺機器上,您在當前目錄(git init)中創建了一個新存儲庫,然後將gitrepo作爲第二個存儲庫克隆到子目錄中。再次,這很好,只要確保它是你想要的。

下面是它如何與第一機器上的裸回購和一個回購在第二工作:

一機:

git init --bare gitrepo.git 

二機:

git clone [email protected]:~/gitrepo.git 
cd gitrepo 
touch test 
git add test 
git commit -a 

# '-u' tells git to track the remote master branch with your local master branch 
git push -u origin master 
6

git push [remote-name] [branch-name]。例如git push origin master

相關問題