Home  >  Q&A  >  body text

visual-studio-code - 为什么ubuntu 系统上每次进行git 指令时如果不加上sudo就会提示权限不够,无法操作呢?

比如我在任意文件夹如/opt/html下建立git仓库,输入git init指令,回车就会提示/opt/html/.git: 权限不够,加上sudo 之后就可以,我想不加sudo 就给他权限可以吗,这样每次sudo好麻烦,而且我现在用visual studio code来版本控制,在vs code里面是用不了sudo的哦,那么我怎么去初始化,添加,提交管理我的代码呢?

世界只因有你世界只因有你2751 days ago844

reply all(3)I'll reply

  • PHPz

    PHPz2017-05-02 09:51:11

    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.

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-02 09:51:11

    Is git installed under root permission? Uninstall git, and then install git under your user rights.

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-02 09:51:11

    Clone repo under root permission

    yu install mei guan xi

    reply
    0
  • Cancelreply