我昨天能够罚款.但是今天(我没有改变任何东西),当我承诺:
$ git add config.h
$ git commit -m "Update config.h to reset the values"
error: Couldn't set refs/heads/master
fatal: cannot update HEAD ref
Run Code Online (Sandbox Code Playgroud)
我知道在拉或推过程中也可能发生这种错误.但我还没有找到解决方案来修复它.
我的.git/config文件如下所示:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[remote "origin"]
url = git@SOME_URL
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
Run Code Online (Sandbox Code Playgroud)
Rah*_*pta 10
看来你已经失去了你HEAD,所以你必须重新创建它.你可以用它做到这一点.
echo ref: refs/heads/master >.git/HEAD
Run Code Online (Sandbox Code Playgroud)
这将HEAD在.git文件夹中创建一个文件.那应该可以解决你的问题.
另外,尝试git fsck命令.它验证数据库中对象的连接性和有效性.
git fsck --lost-found
Run Code Online (Sandbox Code Playgroud)
使用此选项扫描无法访问的对象.它会根据类型将悬空物体写入.git/lost-found/commit/或.git/lost-found/other/.如果对象是blob,则将内容写入文件,而不是其对象名称.
小智 6
fatal: couldn't set 'refs/heads/my-branch'当我有 2 个 VS Code 副本时,我遇到了这个问题 ( ),每个副本都带有检查到相同提交的集成终端。除了一个版本的 VS Code 处于 WSL(Linux 的 Windows 子系统)模式。我关闭了 WSL VS Code,并立即能够在 vanilla 非 WSL VS Code 中提交。
| 归档时间: |
|
| 查看次数: |
13870 次 |
| 最近记录: |