git 无法锁定 refs/heads/master
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11228436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to lock refs/heads/master
提问by mu_sa
I am relativly new to git and am facing this problem. The git push command shows the error below. I will explain to you from the begining what i had been trying to do . I created a submodule, commited and pushed it. The push throws the error below.
我对 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://[email protected]/majuri/breakit-web-app.git
! [remote rejected] master -> master (failed to lock)
error: failed to push some refs to 'ssh://[email protected]/majuri/breakit-web-app.git'
Here is a screen shot:
这是一个屏幕截图:
After that i tried some solutions but none of them worked. I will also explain breifly what i have been trying
之后我尝试了一些解决方案,但没有一个奏效。我还将简要解释我一直在尝试的内容
1 : From the bitbucket repo i noticed there are some danggling commits (the red arrow in picture 2) so i gave the following commands to solve that git gc and git prune.
1:从 bitbucket 存储库中,我注意到有一些悬空提交(图 2 中的红色箭头),因此我给出了以下命令来解决 git gc 和 git prune。
2: I also tried commands like git revert HEAD and git push origin HEAD --force but none seem to worked..
2:我也尝试过像 git revert HEAD 和 git push origin HEAD --force 这样的命令,但似乎都没有工作..
Other details:
其他详情:
$ 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
Thank you
谢谢
回答by Flows
You have to update the HEAD known by git. It will be transparent for you.
您必须更新 git 已知的 HEAD。这对你来说是透明的。
1 -Go to master
branch
1 -去master
分行
git checkout master
2 -Get updates from the remote to your local repository
2 -从远程获取更新到本地存储库
git fetch
3 -Update your local repository using rebase instead of merge. See there difference between git pull
and git rebase
3 -使用 rebase 而不是 merge 更新您的本地存储库。查看和之间的区别git pull
git rebase
git rebase origin/master
4 -Push your master
branch
4 -推送你的master
分支
git push origin master:master