2012-09-14 34 views
21

我試圖推動從我的本地分支到原產地。分支名稱和路徑相同。我一直在推動和從這個分支拉了一段時間,從來沒有遇到過問題。但突然間,它開始表現糟糕。上次當我試圖推到起源與下面的命令:臭名昭着的Git錯誤:遠程拒絕(失敗鎖定)

git push origin feature/Prizefulfilment 

它給了我以下errror:

72c6c1da98e5cff4484e254a538d9e3b472156ff but expected 0000000000000000000000000000000000000000 

我用Google搜索周圍,但沒有找到一個很令人滿意的解決它。

我確切的錯誤看起來像以下:

$ git push origin feature/Prizefulfilment 
Counting objects: 126, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (75/75), done. 
Writing objects: 100% (78/78), 8.83 KiB, done. 
Total 78 (delta 61), reused 0 (delta 0) 
error: Ref refs/heads/feature/Prizefulfilment is at 72c6c1da98e5cff4484e254a538d9e3b472156ff but expected 0000000000000000000000000000000000000000 
remote: error: failed to lock refs/heads/feature/Prizefulfilment 
To [email protected]:OpusOneSCRUM 
! [remote rejected] feature/Prizefulfilment -> feature/Prizefulfilment (failed to lock) 
error: failed to push some refs to '[email protected]:OpusOneSCRUM'` 

任何想法?

+1

你可能想在本地和遠程運行'git fsck'以確保沒有受到嚴重損壞。 – singpolyma

+0

它在我的本地'檢查對象目錄:100%(256/256)完成後返回了一些懸而未決的提交。 檢查對象:100%(106152/106152),完成。 晃來晃去的blob 4118c6392bbea95a6404d40344e12ff8fe1e64c8 晃來晃去的blob a34f2078115375df3749567e01793e556f0e5ade 晃來晃去的blob 9a5e545d9056200834f74d6426144269974467a0 晃來晃去的blob 867c5821823a875e724203b5bc8bbf65c8b72931 晃來晃去的blob 128ccc6d40e4090cd725d37867308e525825b991 晃來晃去的blob 5b91603a188d5f13af4ef56b0f62d6d8caff92b4 晃來晃去的blob c6a5241f7a4c23a68456526adf94f3c784d1df69' 和更蹺着 – TeaLeave

+0

我也跟着用git修剪,它去掉了很多緊靠一些晃來晃去的斑點懸掛提交仍然存在...... – TeaLeave

回答

28
git push feature/prizeFulfilment: feature/Prizefulfilment 

,這類似this answer

For the record, I believe the root cause of this problem was the difference in capitalisation between the local and remote branch names, and the case-insensitive nature of the Windows share that hosted the remote repository.

We just encountered this exact same error and were able to resolve the problem simply by renaming the local branch to match the capitalisation of the existing remote branch.

嘗試,並確保使用本地和遠程分支機構之間的同資本。

第二條命令使prizeFulfilment與遠程Prizefulfilment之間的鏈接顯式化,這就是它工作的原因。但是,保持本地分支的這種差異並不是一個好的解決方案。

+0

感謝您的意見,這是有益的:)。 – TeaLeave

3

發生在我身上的是git改變了我本地分支的大小寫。我有一個名爲Feature/blahBlah的舊分支和一個名爲feature/fooBar的新分支。後者自動重命名爲Feature/fooBar,因爲git將分支存儲爲文件夾,並且我不能使用不同的大小寫替換相同的文件夾名稱。

要修復它,我必須進入.git/refs/heads並將'Feature'重命名爲'feature'`,這樣所有分支都將保持一致。

-1

當你得到這樣的消息,先別拉從遠程branch.Then操作做俯臥撐operation.When有人推動文件到遠程服務器,它會轉向主分支(如果遠程分支是master,它可以是任何名稱)到其他地方。您需要在本地存儲庫中更新它,以便本地存儲庫中的origin/master將向前移動。然後在本地存儲庫中添加文件並將其提交。然後執行推送operation.It爲我工作

0

在我的情況下,我已經簽出了所有小寫字母的分支。這導致了遠程分支和本地分支名稱之間的不一致。

遠程分支是INT-4368-some-feature-details,而本地分支是int-4368-some-feature-details。

要修復,我進入.git \ refs \ heads \ feature並重命名分支名稱以匹配遠程。然後去命令行並跑

git checkout INT-4368-some-feature-details 
2

我看到這個錯誤發生的原因是前一個分支存在與我的新分支路徑名稱相同的名稱。例如:

  • 遠程設有分公司:some_feature
  • 當地設有分公司:some_feature/some_subfeature
  • 本地推分支some_feature/some_subfeature遠程
  • 遠程有錯誤:(failed to lock)

解決方案:

  • 重命名本地分支some_feature/some_subfeaturefoo/some_subfeature
  • 刪除遠程分支some_feature
相關問題