error: could not lock config file filepath/../.git/config :permission denied

error: could not lock config file filepath/../.git/config :permission denied

我在路径 /home/bhishan/Copy/try 中创建了一个名为 "try" 的文件夹 然后在该文件夹中我给出了一些命令:

我的命令如下:

curl -s -O \
http://github-media-downloads.s3.amazonaws.com/osx/git-credential-osxkeychain

chmod u+x git-credential-osxkeychain

sudo mv git-credential-osxkeychain `dirname \`which git\``

git config --global credential.helper osxkeychain

git init

git remote add origin https:

git remote add origin https:

git push origin master

==============================

它工作正常,但是,当我尝试删除 try 文件夹时,我无法删除该文件夹。 我也不能下命令:

git init

在 try 文件夹内(我在那里有一个 .git 文件夹)

=========================================== ========

我的命令行和错误报告是这样的:

bhishan@bhishan-HP-Pavilion-dv6-Notebook-PC:~/Copy/try$ git init
error: could not lock config file /home/bhishan/Copy/try/.git/config: Permission denied

现在,我的问题是如何删除名为 "try" 的文件夹?

当您使用 sudo 到 运行 命令并产生文件创建等副作用时,会出现此类问题。

在您的主目录中找到 root 拥有的文件和目录是很常见的。在这种情况下,您的 .git/config 文件似乎归 root 所有,因此在您尝试锁定它时会出现权限错误。

~/Copy/try 目录中的

sudo chown bhishan -R .git 应该可以解决权限问题。

我正在添加这个问题的答案,因为我在尝试解决几乎相同的问题时来到这里。

git 中也有这个问题。但据我所知,不仅仅是我的 git 有权限被拒绝的问题,还有整个应用程序文件夹。即使我尝试在另一个项目中使用 git,它也能正常工作。

要与@Aaron D 的答案相加,您可以使用 $(whoami) 而不是 bhishan。就像这样:

$ sudo chown $(whoami) ~/Copy/try

P.S。 回答你的问题:

now, my question is how can i delete the folder called "try" ?

您可以运行这个命令:

$ sudo rm -rf /home/bhishan/Copy/try
git init

.git 文件夹被删除的情况下,这对我有用。

就我而言,我只是使用了 git init 命令,一切正常。

我一直在努力解决这个问题,git 配置 http.postBuffer 157286400 在我的案例中成功运行。