Git repository lost its remote branches?

前端 未结 2 1854
醉话见心
醉话见心 2020-12-15 19:00

I have a git repository that has a remote set up (\"git fetch\" works), but it doesn\'t have any remote branches: the \".git/refs/remotes\" folder doesn\'t

相关标签:
2条回答
  • 2020-12-15 19:03

    [Edit, April 2017] If you made your original clone with --single-branch, your remote.origin.fetch setting will be the problem. If you used a --depth limit, that too implies --single-branch. Restore the normal remote.origin.fetch value described below and you will get a fuller clone.


    Normally, just running git fetch should restore your remote-tracking branches.

    If git fetch is not restoring them, then I wonder: what goes git config --get-all remote.origin.fetch print? (This assumes the remote is named origin; if not, substitute the actual name.) It should be set to +refs/heads/*:refs/remotes/origin/* (again assuming the name origin). Special cases (such as fetching notes) might add more lines.

    0 讨论(0)
  • 2020-12-15 19:23

    This solved my problem

    git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/*

    When I excute vi .git/config , I loose the fetch line:

    fetch = +refs/heads/*:refs/remotes/origin/*

    0 讨论(0)
提交回复
热议问题