git github 错误:将对象添加到存储库数据库的权限不足
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18324279/
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
github error: insufficient permission for adding an object to repository database
提问by CHarris
I used to be able to do, from my App folder:
我曾经可以从我的 App 文件夹中执行以下操作:
git add .
git commit -m "commit details"
git push
and the latest version of my app on my local machine would be backed up on in my master repo, on github.
我的本地机器上的最新版本的应用程序将备份在我的主存储库中,在 github 上。
Now, when I get as far as just the git add .
command, I get:
现在,当我得到git add .
命令时,我得到:
mycompaq@ubuntu:~/myapp$ git add .
error: insufficient permission for adding an object to repository database .git/objects
error: app/views/reviews/update.js.erb: failed to insert into database
error: unable to index file app/views/reviews/update.js.erb
fatal: updating files failed
mycompaq@ubuntu:~/myapp$
I read in a message on Stackoverflow the way to overcome a similar problem was with:
我在 Stackoverflow 上的一条消息中读到了克服类似问题的方法是:
chown -R user:user /project/directory
But seeing as I got in a whole load of troublein the first place by running commands I wasn't sure about, I want to know if this is the command for me. What does it do? Can it be undone?
但是看到我首先通过运行我不确定的命令遇到了一大堆麻烦,我想知道这是否适合我。它有什么作用?可以撤销吗?
What should the exact syntax be, if the user is 'Christophe', and the folder where my Rails app is stored is called 'myapp'. I mean should it be
如果用户是“Christophe”,并且存储我的 Rails 应用程序的文件夹称为“myapp”,那么确切的语法应该是什么。我的意思应该是
chown -R user:christophe /myapp/app/views/reviews/update.js.erb
Sorry for all the questions.
抱歉有这些问题。
回答by Gabriele Petronella
chown [ -f ] [ -h ] [ -R ] Owner [ :Group ] { File ... | Directory ... }
From the man page
从手册页
The chown command changes the owner of the file specified by the File parameter to the user specified by the Owner parameter. The value of the Owner parameter can be a user ID or a login name found in the /etc/passwd file. Optionally, a group can also be specified. The value of the Group parameter can be a group ID or a group name found in the /etc/group file.
chown 命令将 File 参数指定的文件的所有者更改为 Owner 参数指定的用户。Owner 参数的值可以是在 /etc/passwd 文件中找到的用户 ID 或登录名。也可以选择指定一个组。Group 参数的值可以是在 /etc/group 文件中找到的组 ID 或组名称。
About the -R option
关于 -R 选项
-R
Descends directories recursively, changing the ownership for each file. When a symbolic link is encountered and the link points to a directory, the ownership of that directory is changed but the directory is not further transversed.
-R
递归下降目录,更改每个文件的所有权。当遇到符号链接并且该链接指向目录时,该目录的所有权会更改,但不会进一步横越该目录。
So
所以
chown -R user:christophe /myapp/app/views/reviews/update.js.erb
Would change the owner of the update.js.erb
file to the user user
in the group christophe
, which is probably not what you want.
会将update.js.erb
文件的所有者更改为user
组中的用户christophe
,这可能不是您想要的。
In your case changing the owner of the repo to yourself, i.e.
在您的情况下,将回购的所有者更改为您自己,即
sudo chown -R christophe /path/to/your/local/repo
should suffice.
应该足够了。
If you don't know your user name, you can find it out with the whoami
command.
如果您不知道您的用户名,可以使用该whoami
命令查找。
回答by Dwain
1) Make sure you're inside the repository where you're getting the error.
1) 确保您位于出现错误的存储库中。
2) Get your username by typing
2)通过键入获取您的用户名
`whoami`
3) Enter this command
3)输入这个命令
sudo chown -R dwain .git/*
sudo chown -R dwain .git/*
回答by imlegend19
You can give access to all the files in .git/ folder. Just run the following command:
您可以访问 .git/ 文件夹中的所有文件。只需运行以下命令:
sudo chmod a+xrw .git/*
回答by SagarPPanchal
Simply I permitted my folders and its files with sudo command
只是我使用 sudo 命令允许我的文件夹及其文件
sudo -r 777 directory/