当前位置: 动力学知识库 > 问答 > 编程问答 >

github - Branch and tag information disappeared from the refs area in git

问题描述:

After test-driving a git GUI application (SmartGit, in case it makes a difference), I've noticed that my .git/refs/heads directory contains only "master" (there should be three other branches listed), and my .git/refs/tags directory is completely empty. This is in my local copy, the project itself is hosted on GitHub. When I browse it on GitHub, (thankfully) everything is still there.

What's the best way to restore my local branch and tag information? I know that the files in those directories just contain the SHA of the object they point to, but I'm a fairly basic-level git user.

Randy

网友答案:

It seems that your .git/config file has gone missing since it stores information about local branches and what branches they are tracking. You need to checkout these branches again like this:

git checkout --track origin/branch1
git checkout --track origin/branch2

This will recreate the branches and make sure they track the remote branches. To update your tags you need to do:

git fetch --tags
网友答案:

What does git branch -a print? The refs may have been packed by git.

分享给朋友:
您可能感兴趣的文章:
随机阅读: