For example, if I create a git warehouse in any folder such as /opt/html, enter the git init command, and press Enter, it will prompt /opt/html/.git: Insufficient permissions. Just add sudo and it will be fine. I don’t think so. Can I just give him permission when adding sudo? This will be troublesome every time I sudo. Moreover, I now use visual studio code for version control. Sudo cannot be used in vs code. So how do I initialize, add, submit and manage mine? What about the code?
Obviously this is a permissions issue, but ubuntu usually comes with git, so it shouldn’t be the reason @notreami said. Here I need to confirm something:
Are you sure that when you use git in any folder, you will get a prompt about insufficient permissions?
It is recommended to try a more common folder. If your answer is no, it is likely that you do not have enough permissions on the current folder, that is, you do not have write permissions.
Of course, you can also use
ls -l
to view the permission information of the folder.In addition, I tried it on my ubuntu system. I don’t have write permissions on the /opt directory, so I speculate that your html directory was created using
sudo mkdir
, so it’s not surprising that you have a problem like this.Is git installed under root permission? Uninstall git, and then install git under your user rights.
Clone repo under root permission
yu install mei guan xi