git clone問題: warning: remote HEAD refers to nonexistent ref, unable to checkout

來源:互聯網
上載者:User

在git clone的時候出現如下warning:

 

 warning: remote HEAD refers to nonexistent ref, unable to checkout

原因是.git目錄下/.git/refs/heads不存在.git目錄下HEAD指向的檔案,這個時候可以用git show-ref命令,可以看到存在別的

eadc2c7d702724e788d8c6bcdb638b6b228e6ab5 refs/heads/another_branch

可以在此目錄下使用 git branch -m anoter_branch master,將another_branch修改為master,這樣再次複製的時修就不會再有此warning。

 

還可以通過git rev-parse --all可以看到refs目錄下所有的SHA值。

 

可以通過git rev-parse查看某一個branch,tag的SHA值,有沒有辦法反過來知道SHA的值知道其對應的branch以及tag呢,好像不可能?

 

注意:出現此問題的原因是,在本地將一個git工程拷貝過來,然後以此工程為基礎,然後clone過來,由於本地只有my_topic所以clone過來的只有一個my_topic分支,此處不會再clone伺服器遠端的分支。

 

利用本地的bionic複製的時候

git clone bionic local_bionic

然後

git remote show origin
* remote origin
  Fetch URL: /home/hebo/work/test/bionic
  Push  URL: /home/hebo/work/test/bionic
  HEAD branch (remote HEAD is ambiguous, may be one of the following):
    froyo-prod-bb
    my_topic
  Remote branches:
    froyo-prod-bb tracked
    my_topic      tracked
  Local branch configured for 'git pull':
    froyo-prod-bb merges with remote froyo-prod-bb
  Local ref configured for 'git push':
    froyo-prod-bb pushes to froyo-prod-bb (up to date)
此時看到的遠程分支,是以當前複製的對象為遠端,而bionic自已的遠程分支無法再保留,而且所clone的倉庫,當前在什麼分支,clone在本地checkout出來的就是什麼分支。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.