I have installed git as root on my Linux (debian) system before I had created my user. After I created the user I try to run the command (as the new user):
git config --global user.name "myusername"
But I get the error:
error: could not lock config file /home/<username>/.gitconfig: Permission denied
When I type
git config --global --edit
It starts my editor with the path /home/<username>/.gitconfig. I think this is really weird. I have tried to create the .gitconfig file by creating it as sudo and then move the .gitconfig file from /root/.gitconfig to /home/<username>/.gitconfig and lastly chown it to my user, but that does not work either.
Please help me..
EDIT: The problem had to do with user permissions on the home directory of the user. I just ran:
sudo chown username:username /home/username
And then it worked as usal.
Before you go borderline insane, just edit/insert the username by hand inside the .gitconfig? Open it up with the editor of your choice and go ahead:
[user]
name = myusername
email = [email protected]
[color]
branch = on
diff = on
interactive = on
status = on
...
The user.name from the commandline is the [user] + name = combo in the config.
name is just indented with a tab.
Install git
vagrant@precise32:~$ sudo apt-get install git
....Set up your user
vagrant@precise32:/$ sudo useradd -m yourusername
vagrant@precise32:/$ sudo passwd yourusername
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
vagrant@precise32:/$ su - yourusername
Password:
$ ls
$ pwd
/home/yourusername
...Configure git
$ git config --global user.name "yourusername"
$ ls -a
. .. .bash_logout .bashrc .gitconfig .profile
$ cat .gitconfig
[user]
name = yourusername
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