我对 git 比较陌生,正面临这个问题。git push 命令显示以下错误。我将从一开始就向您解释我一直在尝试做的事情。我创建了一个子模块,提交并推送它。推送会引发以下错误。
Salman@PC_HOME ~/git/breakit-web-app (master)
$ git push origin master
error: refs/heads/master does not point to a valid object!
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 421 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: bb/acl: salmanmanekia is allowed. accepted payload.
error: Ref refs/heads/master is at 6a47a0fd398610a75bdab8976f842dc0efd89f86 but expected 00000000000000000000000000000000000000000
remote: error: failed to lock refs/heads/master
To ssh://git@bitbucket.org/majuri/breakit-web-app.git
! [remote rejected] master -> master (failed to lock)
error: failed to push some refs to 'ssh://git@bitbucket.org/majuri/breakit-web-app.git'
这是一个屏幕截图:
在那之后,我尝试了一些解决方案,但都没有奏效。我还将简要解释我一直在尝试的内容。
1:从 bitbucket 存储库中,我注意到有一些悬空提交(图 2 中的红色箭头),所以我给出了以下命令来解决 git gc 和 git prune。
2:我也尝试了 git revert HEAD 和 git push origin HEAD --force 之类的命令,但似乎都没有。
其他详情:
$ git rev-parse --symbolic-full-name master
refs/heads/master
$ git rev-parse master
0da090c5cbde10ff19602a2722ae05231c30dff5
$ git show-ref master
0da090c5cbde10ff19602a2722ae05231c30dff5 refs/heads/master
6a47a0fd398610a75bdab8976f842dc0efd89f86 refs/remotes/origin/master
谢谢