How to set permisions for git so it runs without sudo

16,471

As you can see in your ls output, the .git directory is owned by root, and you don't have write access to it. Fix it with this command:

sudo chown -R wiktor:wiktor /var/www/html/apps/blog/.git

This will transfer file ownership of the git directory and everything in it back to you.

Share:
16,471

Related videos on Youtube

DevWL
Author by

DevWL

BY DAY and NIGHT: PHP, JS

Updated on September 18, 2022

Comments

  • DevWL
    DevWL over 1 year

    I have problem with git permisions. When I run git from console i have to add sudo in front of it to get it to work, but when I use NetBeans GUI the script runs without the 'sudo' command and in result I am promped with this error message:

    [ java.io.IOException: No access ]
    

    What do i have to do to make it work ?

    Permision of my /var/www/html/apps/blog directory content

    wiktor@wiktor-VB:/var/www/html/apps/blog$ ls -la
    all 140
    drwxr-xr-x  9 wiktor wiktor  4096 lis 27 23:28 .
    drwxr-xr-x  5 wiktor wiktor  4096 lis 27 21:32 ..
    drwxr-xr-x  6 wiktor wiktor  4096 lis 27 21:34 app
    drwxr-xr-x  2 wiktor wiktor  4096 lis 27 21:33 bin
    -rw-r--r--  1 wiktor wiktor  2318 lis 23 13:18 composer.json
    -rw-r--r--  1 wiktor wiktor 64050 lis 23 13:18 composer.lock
    drwxr-xr-x  8 root   root    4096 lis 27 22:23 .git
    -rw-rw-r--  1 wiktor wiktor   204 lis 27 23:28 .gitignore
    -rw-r--r--  1 wiktor wiktor  1065 lis 23 13:18 LICENSE
    drwxrwxr-x  3 wiktor wiktor  4096 lis 27 23:28 nbproject
    -rw-r--r--  1 wiktor wiktor  2448 lis 23 13:18 README.md
    drwxr-xr-x  3 wiktor wiktor  4096 lis 23 13:18 src
    -rw-r--r--  1 wiktor wiktor  1308 lis 23 13:18 UPGRADE-2.2.md
    -rw-r--r--  1 wiktor wiktor  1962 lis 23 13:18 UPGRADE-2.3.md
    -rw-r--r--  1 wiktor wiktor   356 lis 23 13:18 UPGRADE-2.4.md
    -rw-r--r--  1 wiktor wiktor  8499 lis 23 13:18 UPGRADE.md
    drwxr-xr-x 14 wiktor wiktor  4096 lis 27 21:34 vendor
    drwxr-xr-x  3 wiktor wiktor  4096 lis 27 21:34 web
    
    • s3lph
      s3lph over 8 years
      What does Brak dostępu mean?
    • DevWL
      DevWL over 8 years
      oh sorry! :) shame on me. It means access denied
    • DevWL
      DevWL over 8 years
      or simple no permisions to execute this command from NetBeans GUI
    • s3lph
      s3lph over 8 years
      What does ls -l /usr/bin/git give back?
    • DevWL
      DevWL over 8 years
      my project is located in: /var/www/html/apps/blog
    • s3lph
      s3lph over 8 years
      What are the permissions on /var/ww/html/ and subdirectories?
    • DevWL
      DevWL over 8 years
      added to the question
  • DevWL
    DevWL over 8 years
    It works. Tahank you for your time and help !
  • SebastianG
    SebastianG almost 4 years
    Thanks, took a while to find this but it works.