[英]fatal: Reference has invalid format: 'refs/heads/master~'
[英]Git fatal: Reference has invalid format: 'refs/heads/master
我正在使用Dropbox
來同步git
存儲庫,但是現在當我嘗試push
時出現錯誤:
fatal: Reference has invalid format: 'refs/heads/master (MacBook-Pro's conflicted copy 2012-10-07)'
因此,似乎Dropbox檢測到沖突並創建了副本。 好的,沒問題,所以我刪除了沖突的文件。 盡管如此,仍然可以獲得上述git錯誤。
$ git checkout master
M index.html
Already on 'master'
$ git add .
$ git commit -a -m "Cleanup repo"
[master ff6f817] Cleanup repo
1 file changed, 5 insertions(+), 5 deletions(-)
$ git push
fatal: Reference has invalid format: 'refs/heads/master (MacBook-Pro's conflicted copy 2012-10-07)'
The remote end hung up unexpectedly`
我怎樣才能解決這個問題? 謝謝。
如果您不確定這個,請備份您的倉庫,因為這些命令是不可逆轉的。
首先,轉到您的repo目錄。
cd myrepo
然后遞歸搜索沖突的文件並刪除它們
find . -type f -name "* conflicted copy*" -exec rm -f {} \;
最后,從git的packed-refs文件中刪除任何“沖突的”引用
awk '!/conflicted/' .git/packed-refs > temp && mv temp .git/packed-refs
沖突的文件可能在多個地方,我會調查:
.git/logs/refs/remotes/origin/
.git/logs/refs/heads/
.git/refs/remotes/origin/
.git/refs/heads/
或者你可以在.git
子目錄中隨處find . -name '*conflicted*'
: find . -name '*conflicted*'
find . -name '*conflicted*'
或者,否則,使用git branch -a
列出活動分支,並刪除( git branch -d
)可疑的任何內容。
當我的同事在Dropbox更新之前推送他的更改並關閉PC時,我們的團隊也會遇到這種情況。
我這么簡單地解決了。
剛剛刪除了沖突的副本。 (XXXX的沖突副本yyyy-mm-dd)
並正常拉。
請注意,我的同事在搞砸之前已經做了更改。 他再次推動他的改變。 這次沒有關機。 :)
我能夠從.git文件夾中刪除所有沖突的文件,但我繼續收到有關不再存在的文件的錯誤。
我的修復是打開.git/refs/packed_refs
並刪除包含“沖突”文本的行。
對我來說它給出了錯誤: fatal: Reference has invalid format: 'refs/tags/r0.2:3'
您可以轉到/.git/packed_refs文件並刪除refs/tags/r0.2:3
然后它開始工作了。 但為什么它發生在我不知道的第一個地方。
首先嘗試使用git checkout master
來獲得健康,命名良好的分支。
我得到了同樣的錯誤
致命:參考格式無效:'refs / heads / somebranch(1)'
用於以下命令
git branch
然后,我使用命令搜索錯誤的名稱(分支名稱后跟(1))
find . -name 'somebranch (1)'
它顯示了以下結果
./.git/refs/heads/somebranch(1)
這是某些分支 IMO的重復版本。 所以,我通過執行delete命令后面的find命令刪除了它
find . -name 'somebranch (1)' -print -exec rm -rf {} \;
然后branch命令成功運行
git branch
我遇到了類似的錯誤,如
fatal: Reference has invalid format: 'refs/heads/user-search-api (Sithu's conflicted copy 2016-01-08)'
只需在遠程Dropbox存儲庫中刪除文件.git/refs/heads/user-search-api (Sithu's conflicted copy 2016-01-08)
就可以解決問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.