2009-05-05 43 views
178

我剛開始使用git和github。我按照他們的指示,在最後一步遇到了錯誤。我正在檢查一個當前不受源代碼控制的現有目錄(項目大約一週)。除此之外,我的用例應該是工廠的運行。在新存儲庫上推送原點主錯誤

這裏發生的事情:

$ git push origin master 
error: src refspec master does not match any. 
fatal: The remote end hung up unexpectedly 
error: failed to push some refs to '[email protected]:{username}/{projectname}.git' 

GitHub的說明:

Global setup: 

    Download and install Git 
    git config --global user.name "Your Name" 
    git config --global user.email {username}@gmail.com 

Next steps: 

    mkdir projectname 
    cd projectname 
    git init 
    touch README 
    git add README 
    git commit -m 'first commit' 
    git remote add origin [email protected]:{username}/{projectname}.git 
    git push origin master 
+3

看起來,最初的提交併不出於任何原因。 Git日誌幫助我瞭解提交是否有效。第二天我再次成功嘗試。謝謝! – sutee 2009-05-06 18:30:59

+1

如果你沒有添加任何文件,提交或運行git init,year總會遇到這樣的問題。因此,請始終運行`git status`來查看一切是否正常。 – Raduken 2012-01-26 20:07:35

+0

從現有代碼創建分支到新創建的git存儲庫時出現類似錯誤。通過克隆git存儲庫來解決錯誤。 – user553620 2013-11-27 16:45:04

回答

137

錯誤消息導致你沒有master分公司在本地資源庫的結論。推動你的主要開發分支(git push origin my-local-master:master,它將在github上將其重命名爲master),或者首先進行提交。您無法推送完全空的存儲庫。

1

我固定我的問題....

不知道是什麼問題,只不過使用gitx接口提交我籌備的文件,然後...

$ git push origin master 

工作...

我有同樣的問題...

創造了BORT模板文件中添加一個新文件夾...

$ git commit -m 'first commit' 

$ git remote add origin [email protected]:eltonstewart/band-of-strangers.git 

$ git push origin master 

然後我得到了同樣的錯誤......

error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '[email protected]:eltonstewart/band-of-strangers.git'

4

我有同樣的錯誤,因爲氣罐說,我曾在我的配置命名的主人沒有當地的分支機構,雖然git branch做列表命名分支主...

要修復它只是添加到您的.git/config中

[branch "master"] 
    remote = origin 
    merge = refs/heads/master 

還挺哈克,但做這項工作

1
error: failed to push some refs to '[email protected]:{username}/{projectname}.git' 

除非你推廣的錯誤信息,它看起來像你從字面上把[email protected]:{username}/{projectname}.git爲遠程的Git回購。您應該使用您的GitHub用戶名填寫{username},並使用您的項目名稱填寫{projectname}

186

我有同樣的問題,然後自己打了個屁,因爲我實際上並沒有添加我的項目文件。

git add -A 
git commit -am "message" 
git push origin master 
0

我mistankly加一個空格後的 - 所以不是-m的我 - 米 只是要看看的。

0

我覺得在老版本的git中,你應該首先提交至少一個文件,然後你可以再次「推送原點大師」。

0

很好..它與空目錄的問題只是沒有別的。我通過在每個目錄中創建一個二進制文件,然後添加它們來解決我的問題。

2

要真正解決這個問題,我使用下面的命令將所有的文件放到提交中。

$ git add . 
$ git commit -m 'Your message here' 
$ git push origin master 

我的問題是,在Git中添加-u命令實際上並沒有添加新的文件和git的添加是不支持我的安裝混蛋-A命令。因此,正如在這個線程中提到的那樣,我試圖實現的提交是空的。

0

初始添加&承諾像一個魅力工作。我想這只是理解Git在存儲庫中管理項目的方法。

之後,我設法直接推送我的數據,沒有麻煩。

1
cd app 

git init 

git status 

touch test 

git add . 

git commit -a -m"message to log " 

git commit -a -m "message to log" 

git remote add origin 

git remote add origin [email protected]:cherry 

git push origin master:refs/heads/master 

git clone [email protected]:cherry test1 
1

有同樣的問題在一分鐘前,然後固定它

創建github上稱爲WordPress的一個倉庫......

cd wordpress 
git init 
git add -A 
git commit -am 「WordPress 3.1.3″ or any message 
git remote add origin [email protected]:{username}/wordpress.git 
git push -u origin master 

這應該努力解決的Refspec問題

26

我有同樣的問題。我刪除,則git的文件夾遵循以下命令

  1. $ git init
  2. $ git add .
  3. $ git remote add origin [email protected]:project/project.git
  4. $ git commit -m "Initial version"
  5. $ git push origin master
3

確保您在樹枝上,至少在主分支

類型:

git branch 

你應該看到:

Ubuntu的用戶:〜/ git的/薑黃,RELENG $ git的分支

* (no branch) 
master 

然後鍵入:

git checkout master 

然後所有的更改將適合主分支(或您選擇的分支) )

1

我有同樣的問題。我錯誤地在機器中創建了小寫的目錄。一旦改變了案例,問題就解決了(但浪費了我的1.5小時:() 檢查出你的目錄名和遠程回購的名字是一樣的

6

我剛剛在創建我的第一個Git倉庫時遇到同樣的問題。在Git遠程創建中有一個拼寫錯誤 - 事實證明我沒有使用我的存儲庫的名稱。

git remote add origin [email protected]:Odd-engine 

首先,我刪除舊的遠程使用

git remote rm origin 

然後我重新來源,確保我的出身的名字正是鍵入同樣的方式我出身被拼寫。

git remote add origin [email protected]:Odd-Engine 

沒有更多的錯誤! :)

1

它看起來像這個問題已經有很多答案,但我會與我的權衡,因爲我沒有看到任何解決我的問題。

我在一個全新的github存儲庫上也出現了這個錯誤。事實證明,我推動的用戶沒有推送權限。出於某種原因,這會導致「錯誤:找不到存儲庫」錯誤,而不是某種訪問錯誤。

無論如何,我希望這可以幫助遇到同樣問題的可憐的靈魂。

9

我有同樣的問題。它解決了我的問題。 如果你初始化你的git。你必須做終端

1)git add .

2)git commit -m "first commit"

對於發送到到位桶

3)git push -u origin --all # pushes up the repo and its refs for the first time

0

我只是遇到了這個問題,它似乎是由我的而不是添加一個自定義提交消息上面的默認提交消息(我想,爲什麼寫「初始提交」,當它清楚在下面的Git生成的文本中說同樣的事情)。

當我刪除.git目錄,爲Git重新初始化項目目錄,重新添加GitHub遠程,將所有文件添加到新階段,使用自動生成的消息上方的個人消息,並推送到起源/主。

0

當你在Github上創建一個倉庫時,它會向倉庫添加一個README.md文件,因爲這個文件可能不在你的本地目錄中,或者它可能有不同的內容,git push會失敗。 爲了解決我做了這個問題:

git pull origin master 
git push origin master 

這個時間,因爲我有README.md文件,它的工作。

0

在第一次提交之前,嘗試添加一些像readme.txt這樣的文件。這將「強制」遠程回購創建分支主控以防萬一不存在。這對我很有用。

0

這是一個非常古老的問題,但對於像我這樣最終會在這裏結束的所有新人來說。 該方案僅適用於

error: src refspec master does not match any. 

錯誤創造了新的回購

您需要添加

git config user.email "your email" 
git config user.name "name" 

只有加入電子郵件,姓名等文件添加到Git和提交後

git add . 
git commit -m "message" 

它會像魅力一樣工作

-1

我有同樣的問題,一些用戶已經回答了這個問題。推之前,你必須有你的第一次提交。 現在對於新用戶,我創建了一系列簡單的步驟。在這之前,你需要安裝的Git並在命令行中運行:

  • 混帳配置user.email「電子郵件」
  • 混帳配置user.name「名」

的創建步驟遠程倉庫(我使用Dropbox的遠程倉庫):

1. create a directory in Dropbox (or on your remote server) 
2. go to the Dropbox dir (remote server dir) 
3. type git command: git init --bare 
4. on your local drive create your local directory 
5. go to local directory 
6. type git command: git init 
7. add initial files, by typing git command:: git add <filename> 
8. type git command: git commit -a -m "initial version" (if you don't commit you can't do the initial push 
9. type git command: git remote add name <path to Dropbox/remote server> 
10. git push name brach (for first commit the branch should be master) 
0

我有這樣的錯誤太多,我把承諾不推空項目一樣,很多人做的,但不工作

問題是SSL,Y提下

git config --system http.sslverify false

而在這之後一切正常:)

git push origin master

0

我有同樣的問題/ error.I在做git push -u origin master而不是我只是做了git push origin master,它的工作。