【问题标题】:Fatal cannot lock ref / Permission denied in Git致命无法锁定 ref/Git 中的权限被拒绝
【发布时间】:2021-07-23 06:27:53
【问题描述】:

查看了关于 SO 的相关文章,但没有成功。

我在 macOS 上:

安装 Rust 正常:

rustup update nightly
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly

然后安装这个:

XX-MacBook-Air-2 substrate-node-template % git clone -b v2.0.0 --depth 1 https://github.com/substrate-developer-hub/substrate-node-template
Cloning into 'substrate-node-template'...
remote: Enumerating objects: 46, done.
remote: Counting objects: 100% (46/46), done.
remote: Compressing objects: 100% (42/42), done.
remote: Total 46 (delta 0), reused 29 (delta 0), pack-reused 0
Receiving objects: 100% (46/46), 69.55 KiB | 962.00 KiB/s, done.
Note: switching to '655bfdc6fc922d117849cbcf808ee5bf2dfa1d53'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

然后这个:

cd substrate-node-template/ 

还有这个:

XX-MacBook-Air-2 substrate-node-template % git checkout -b my-first-substrate-chain 

fatal: cannot lock ref 'refs/heads/my-first-substrate-chain': Unable to create '/Users/patrickburns/substrate-node-template/.git/refs/heads/my-first-substrate-chain.lock': Permission denied

非常感谢任何有关如何解决此错误的想法。

【问题讨论】:

  • 错误消息说,除其他外:“如果你想创建一个新分支来保留你创建的提交,你可以(现在或以后)通过使用 -c 和 switch 命令来这样做。” .
  • 第一个提示表明您可以在同一目录中执行两次命令。 XX-MacBook-Air-2 substrate-node-template % 也许你有一个目录 substrate-node-template/substrate-node-template/ 包含代码。

标签: git macos rust substrate


【解决方案1】:

您遇到了权限问题。但是你没有说任何可以说明原因的东西。

就Git而言,我做了你所做的事情,并且完全没有困难:

$ git clone -b v2.0.0 --depth 1 https://github.com/substrate-developer-hub/substrate-node-template
$ cd substrate-node-template/
$ git checkout -b br
Switched to a new branch 'br'

您不能这样做的事实表明您以某种方式将此 repo 克隆到您没有权限的地方。但我们不能从这里告诉你为什么会这样。

【讨论】:

    【解决方案2】:

    您无权在 git 存储文件的本地状态(用于与 repo 同步)的 .git 文件夹中写入/修改某些内容

    我会为您提供解决方案,但在这样做之前您必须考虑一下,因为您可能会产生一些不良影响。

    首先转到执行 git cmd 然后使用的文件夹

    ls -la
    

    您应该拥有每个文件的所有者/组的文件列表。

    查看 .git 文件夹的所有者/组(应该是您)并使用您的更新文件夹和内容的所有者/组。

    所以如果用户/组是 myuser mygroup for .git 文件夹,你可以这样做

    chown -R myuser:mygroup .git
    

    它将更新 .git 的所有者和组,并递归地更新 .git 文件夹中的文件和文件夹。

    现在您应该可以使用您的 git 命令(如果当前用户是拥有 git 文件夹和子文件/文件夹的用户)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-18
      • 2018-10-24
      • 1970-01-01
      • 2020-11-04
      • 2016-08-12
      • 1970-01-01
      • 2019-05-12
      • 2016-10-30
      相关资源
      最近更新 更多