git “无法锁定”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14106782/
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" error
提问by Code-Apprentice
I need some help resolving an error when I push a branch from my local repo to a thumb drive. I believe the problem was caused by switching back and forth between different drives. In particular, I lost one and started using a replacement. Then when I found the original I switched back to it. Now it seems some of my refs/heads are messed up. For example, I get the following output when I try to push a branch:
当我将分支从本地存储库推送到拇指驱动器时,我需要一些帮助来解决错误。我相信问题是由在不同驱动器之间来回切换引起的。特别是,我丢失了一个并开始使用替代品。然后当我找到原版时,我又切换回原版。现在看来我的一些裁判/负责人搞砸了。例如,当我尝试推送一个分支时,我得到以下输出:
$ git push origin android-lite
Counting objects: 111, done.
Compressing objects: 100% (98/98), done.
Writing objects: 100% (109/109), 29.63 KiB, done.
Total 109 (delta 40), reused 0 (delta 0)
error: unable to resolve reference refs/heads/android-lite: No such file or directory
remote: error: failed to lock refs/heads/android-lite
To /media/2AC0-E4E2/devel/src/java/bbct/
! [remote rejected] android-lite -> android-lite (failed to lock)
error: failed to push some refs to '/media/2AC0-E4E2/devel/src/java/bbct/'
$
If I understand correctly, this says that refs/heads/android-lite doesn't exist in origin. However, I'm confused why git doesn't create a new branch. Is there something in my local repo that indicates that the android-lite branch already exists in origin?
如果我理解正确,这表示 refs/heads/android-lite 不存在于原点。但是,我很困惑为什么 git 不创建新分支。我的本地存储库中是否有某些内容表明 android-lite 分支已经存在于原点?
回答by VonC
If debugging the remote repo is too complex (as in this question, with git gc
, git prune
, git fsck
, ...)), you still can:
如果调试远程 repo 太复杂(如在这个问题中,使用git gc
, git prune
, git fsck
, ...),您仍然可以:
git bundle
your current repo, that will give you only one file,- copy that one file on the remote drive
- git clone from that bundle file
- set your current remote address to that new path
git bundle
你当前的回购,只会给你一个文件,- 复制远程驱动器上的那个文件
- git clone 从那个包文件
- 将您当前的远程地址设置为该新路径
This is a bit like "How to synchronize two git repositories", and using a bundle for this task is to make sure you don't have any file error copy.
这有点像“如何同步两个 git 存储库”,使用 bundle 来完成这个任务是为了确保你没有任何文件错误副本。