2013-10-14 125 views
0

我已經開始學習Ruby on Rails和Git。無法將更改推送到遠程Git回購

每當我嘗試任何更改推到我在Github遠程回購,我遇到以下錯誤:

C:\Sites\first>git push origin master 
To [email protected]:piy9/Twitter_clone.git 
! [rejected]  master -> master (non-fast-forward) 
error: failed to push some refs to '[email protected]:piy9/Twitter_clone.git' 
hint: Updates were rejected because the tip of your current branch is behind 
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull') 
hint: before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

注:我添加目錄中的所有文件,並提交更改。我還沒有使用pull或checkout創建任何單獨的分支。

我不是要求解決問題的方法。

git push -f or 
git push origin +HEAD 

爲我工作。

我想知道的是,爲什麼我在嘗試推送到原始分支時遇到錯誤。

+0

此鏈接可能會有幫助:[Pro Git](http://git-scm.com/book/) – Jost

+0

可能是你必須做git pull然後再試一次 – Amar

回答

0

按照這一點,並得到一切正常。 ...

git branch production 
git checkout production 
#do some code changes 
git commit -am "some desparate code changes to try fix heroku" 
git push heroku production:master 

注:這將讓您的工作,並會離開原來的分支。

,或者你可以嘗試這一個也git push heroku +master

+0

沒有試圖直接將它部署到heroku。首先,我試圖對Github上的遠程回購進行一些更改。 – Piyush

+0

然後首先從git中提取代碼。 –

0

貌似遠程分支是你前面的,這意味着它包含了一些當地的分支機構不具有。你可以很容易地看到遠程分支提交,因爲當地的分公司創建或更新時(假設你運行「混帳提取產地/主」先獲取遠程的變化):

git diff HEAD...origin/master 

輸出會回答你的問題,你爲什麼得到錯誤。

現在,我對你遇到的問題的原因猜測是有人有權訪問遠程並推送某些東西,或者你使用github編輯界面修改了某些內容,並且自從上次檢出/提取/合併後提交。如你所做的那樣使用強制推送不是一種好方法,它會混淆歷史,它基本上會用你的副本覆蓋遠程分支,忽略任何遠程更改。

+0

我是唯一一個在這個項目上工作的人。 我在github網站上創建了一個空的repo,然後試圖將本地數據推送到遠程數據庫。 – Piyush

+0

@Piyush然後做差異,看看什麼停止遠程端接受你的推。可能會是新的項目創建添加GPL許可證或自述文件提交,您的本地分支沒有。 –