Why does git branch -t fail with “Not tracking: ambiguous information”?

后端 未结 5 1925
面向向阳花
面向向阳花 2021-02-03 21:10

When I try to create a new branch tracking a remote branch, I get this:

$ git branch -t test origin/foo
error: Not tracking: ambiguous information for ref refs/r         


        
5条回答
  •  南笙
    南笙 (楼主)
    2021-02-03 21:31

    Got it! The problem was that I have previously set up a remote with --mirror, for the purpose of having a backup / public copy of my repository.

    If you run

    git remote add --mirror  
    

    it does not only flag the remote as mirror (which is what I wanted for pushes), but also configures remote..fetch option for the mirror to +refs/*:refs/*, which means that all of your branches suddenly "track" your mirror repository and any attempt to create a tracking branch is going to fail.

    (As an added bonus, running git fetch is going to overwrite all your refs with old ones from your backup repo.)

    The solution that seems to fix this issue is setting remote..fetch to : (which, I hope, means "never fetch anything"). This apparently fixes the tracking issue and eliminates the deadly fetch.

提交回复
热议问题