我正在與一些開發(fā)人員合作,在BitBucket上使用git。我們都在dev分支機(jī)構(gòu)工作,而不是master直到發(fā)布。其中一個開發(fā)人員提交了錯誤的代碼,意外地覆蓋了我自己的代碼,現(xiàn)在我正在嘗試將正確的代碼推回到repo。我已經(jīng)閱讀了這個錯誤幾天了,我不能再推送回購,因為我收到以下錯誤: ! [rejected] master -> dev (fetch first)error: failed to push some refs to 'https://myusername@bitbucket.org/repo_user/repo_name.git'hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (e.g., 'git pull ...') before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.我遵循說明pull,然后我收到合并沖突。輸入合并沖突的消息后,我的本地代碼現(xiàn)在是其他開發(fā)人員意外上傳的錯誤代碼(正如預(yù)期的那樣pull)。所以我用我在提交之前復(fù)制的備份替換了錯誤的代碼,當(dāng)我再次嘗試推送時,我得到了同樣的錯誤。這真的令人沮喪,我真的想幫助我的團(tuán)隊并做出貢獻(xiàn),但我不能因為這個錯誤。有誰知道如何解決這個問題?我非常感謝任何幫助。這些是我為了提交而運(yùn)行的命令,如果它可以幫助任何人:git pull remotename master:devgit add --allgit commit -m "some message"git pull remotename master:devgit push remotename master:dev我原以為如果我遵守這個命令,我就不會收到合并沖突。我想我錯了。再次感謝更新:我應(yīng)該補(bǔ)充一點,我已經(jīng)在Google和stackov
3 回答

小怪獸愛吃肉
TA貢獻(xiàn)1852條經(jīng)驗 獲得超1個贊
git pull <remote> master:dev將獲取remote/master分支并將其合并到您的local/dev分支中。
git pull <remote> dev將獲取remote/dev分支,并將其合并到您當(dāng)前的分支。
我想你說沖突的提交是打開的remote/dev,所以這是你可能想要獲取和合并的分支。
在這種情況下,您實際上并沒有將沖突合并到您的本地分支中,這有點奇怪,因為您說您在工作副本中看到了錯誤的代碼。您可能想要檢查發(fā)生了什么remote/master。

慕村9548890
TA貢獻(xiàn)1884條經(jīng)驗 獲得超4個贊
當(dāng)我們嘗試推送到遠(yuǎn)程存儲庫但是在遠(yuǎn)程創(chuàng)建了一個尚未提取的新文件時,就會發(fā)生這種情況Readme。在那種情況下,錯誤說
git拒絕更新
因為我們沒有在當(dāng)?shù)丨h(huán)境中使用更新的遙控器。所以先從遙控器拉出來
git pull
它將更新您的本地存儲庫并添加新Readme文件。然后將更新的更改推送到遠(yuǎn)程
git push origin master
- 3 回答
- 0 關(guān)注
- 952 瀏覽
添加回答
舉報
0/150
提交
取消