I've moved back from my work MBP to my home MBP. The work one allowed to run git commands without the need for sudo. But I'm finding this is a requirement on my home machine.
I would prefer to be able to run git
commands without sudo
.
I looked at the git commands in /usr/bin
, and they all have rwxr-xr-x
(755
), and are owned by root
and group wheel
. I suppose I could change this to rwxrwxrwx
(777
), but I'm wondering if there's a better way. I'm thinking of adding my user to the wheel
group; but would there be other side effects?
The Git command uses credentials and configuration stored in the current user's home directory; when you run as sudo , this code is going to be looking at the root home directory, not your home directory and thus miss this context. In most cases, it should not be necessary to use sudo .
You will need to do two things: Put the username in your URL: ssh://[email protected]/soft.git. Make your SSH key available to the root user, because it will look under /root/. ssh instead of /home/user/.
The permission on the git
executable are fine; there is no reason you should need to change that, or change your group.
It's more likely that the permissions on your Git checkout are wrong. If you accidentally checked it out with something like sudo git clone ssh://user@host/project.git
, or at some point you performed some kind of operation in the repository that caused some files to be owned by root, git
running under your account won't be able to write to those files.
Most likely, what you need to do is chown -R <user> myproject
in order to make your project owned by your own user account, rather than root.
If you were prompted like this:
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
And then you ran:
sudo git init .
After updating xcode license. Just remove the init and re-init w/o sudo
sudo rm -rf .git
git init .
This fixed my issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With