我对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 and 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
谢谢
git show-ref refs/remotes/origin/master
的输出是什么? - vergenztgit fetch origin
输出什么?也许你的远程跟踪分支不同步了或者出了什么问题...? - vergenztgit rev-parse --symbolic-full-name master
,git rev-parse master
å’Œgit show-ref master
的输出是什么? - Richard Hansenrefs/heads/master - mu_sa