0

I would like to use git without taping sudo everytime i tape a command on CentOS

and i have no idea how to do it. I checked on google and i found this some command with chown but none of them worked

Edited : I don't want to use sudo, i want to use git without taping sudo everytime. For instance, every time i tape git checkout i have an error of permission and i need to tape sudo git checkout and password to do this

1
  • 3
    Welcome to Super User! Can you edit your post to describe your problem more fully? Why do you need to use sudo with git in the first place?
    – bertieb
    Sep 14, 2018 at 10:21

1 Answer 1

1

Probably you don't have write permissions on the folder you want to checkout to.

What permissions do you have there? Run

ls -la </path/to/gitfolder>

You should get something like:

$ ls -la /path/to/gitfolder
total 8
drwxrwxr-x  2 user group 4096 Sep 14 14:03 .
drwxr-xr-x 24 user group 4096 Sep 14 14:03 ..

Here at . there should be your user name at user and not root (if you run it on your own computer).

If some files are owned by root, then you could change the ownership of your current folder and files with this command

chown -R <user> .
6
  • pwd /home/user ls -la drwxrwxr-x. 4 user user 4096 13 sept. 14:16 Folder This is what i have in this Folder
    – Cornos
    Sep 14, 2018 at 12:15
  • the problem was on the directory it was owned by root indeed Problem solved with chown -R <user>
    – Cornos
    Sep 14, 2018 at 12:58
  • 1
    All of that because i've done a git clone with a sudo I guess doing a git clone with sudo is not the best practice
    – Cornos
    Sep 14, 2018 at 13:58
  • @Cornos please use the checkmark next to this answer to indicate that it is the correct answer. This will give OP a few more points, mark this question as solved, and show others with similar questions that this is the solution that worked for you. Sep 17, 2018 at 22:20
  • @music2myear thank you for the recall, but do you mean that the green check mean solved or i should edit the title with [solved]?
    – Cornos
    Sep 19, 2018 at 21:02

Not the answer you're looking for? Browse other questions tagged .