2016-03-09 106 views
1

我在Android Studio上創建了一個項目並將文件推送到Github。我的同事們可以拉動這個項目並且可以工作。我做了該項目的幾個改變自己,致力於但是當我推開,它給了我下面的錯誤Android Studio推送到Github

Push rejected: Push to origin/master was rejected

我工作在Linux上

我試着混帳推-u起源主 我碰到下面的錯誤

To https://github.com/devilape/Iimpacttest.git 
    ! [rejected]  master -> master (non-fast-forward) 
    error: failed to push some refs to 'https://github.com/devilape/Iimpacttest.git' 
    hint: Updates were rejected because the tip of your current branch is behind 
    hint: its remote counterpart. Integrate the remote changes (e.g. 
    hint: 'git pull ...') before pushing again. 
    hint: See the 'Note about fast-forwards' in 'git push --help' for details. 
+0

'git update'執行成功嗎? – Raptor

+0

[Git push error'\ [remote rejected \] master - > master(branch is currently checked out)']可能重複'](http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected -master-master-branch-is-currently-checked) – paulsm4

回答

2

更新回答

既然你正與.idea/workspace,你和其他開發問題elopers,首先應該將.idea folder添加到.gitignore文件中。

由於.idea文件夾包含IDE配置文件,因此它們不需要由Git進行跟蹤。爲了防止混帳從跟蹤此文件夾:

git rm -r --cached .idea/ 
git commit -a -m "Removed .idea from being tracked by git" 

然後,

git push origin master 

有關使用IntelliJ IDEA的配置文件中的相同問題的更多信息,你可以參考下面的問題,以及

Git won't ignore files

git to ignore a hidden directory in the local repo


Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes

這表明您應該先更新您的本地資源庫與新的承諾,其他開發人員製作並被推到了remote.So:

git pull origin master 

然後執行合併並解決合併可能發生的衝突。

然後

git push origin master 

git push -u origin master 

將解決這個問題,你的工作轉移到遠程倉庫。

+0

在我使用git pull命令之後,它說我應該在我合併之前提交更改。我做到了。但是,當我嘗試再次拉它時,它會顯示錯誤並中止該過程。這裏的錯誤:從https://github.com/devilape/Iimpacttest *分支主 - > FETCH_HEAD 錯誤:您的本地更改以下文件將被合併覆蓋: \t .idea/workspace.xml 請,在合併之前提交更改或隱藏它們。 正在中止 –

+0

我的git總體策略是:如果來自前3次堆棧溢出搜索的2-3條命令沒有解決問題,則 1.爲本地更改生成補丁 2.將補丁保存在別處 3.刪除目錄 4.檢出新副本 5.應用補丁 6.提交併上載。 7.並告訴我自己,git .. pff .. :) – subin