2013-07-28 66 views
3

在我创建我的用户之前,我在我的Linux(debian)系统上以root用户身份安装了git。我创建的用户后,我尝试运行命令(如新用户):无法为用户创建gitconfig文件

git config --global user.name "myusername" 

但我得到的错误:

error: could not lock config file /home/<username>/.gitconfig: Permission denied 

当我键入

git config --global --edit 

它开始我的编辑与路径/home/<username>/.gitconfig。我觉得这很奇怪。我试图创建.gitconfig文件,将其创建为sudo,然后将.gitconfig文件从/root/.gitconfig移动到/home/<username>/.gitconfig,最后将chown移动到我的用户,但这也不起作用。 请帮助我..


编辑: 问题曾与用户的主目录用户权限执行。我刚刚跑:

sudo chown username:username /home/username 

然后它作为用途工作。

回答

4

在你走近界线疯狂之前,只需在.gitconfig内手动编辑/插入用户名?从我

gitconfig摘录:你选择的编辑器打开它,并继续

[user] 
     name = myusername 
     email = [email protected] 
[color] 
     branch = on 
     diff = on 
     interactive = on 
     status = on 

... 

username from the commandline is the [user] + name = combo in the config。
name只是缩进一个选项卡。

+0

但问题是它不存在于用户空间中?好吧,但生病尝试,并用手做...我回来给你,谢谢 – patriques

+0

我的问题的解决方案是上面,看看是否有兴趣,感谢您的合作和您的建议。 – patriques

3

安装混帐

[email protected]:~$ sudo apt-get install git 

....设置您的用户

[email protected]:/$ sudo useradd -m yourusername 
[email protected]:/$ sudo passwd yourusername 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully 
[email protected]:/$ su - yourusername 
Password: 
$ ls 
$ pwd 
/home/yourusername 

...配置的git

$ git config --global user.name "yourusername" 
$ ls -a 
. .. .bash_logout .bashrc .gitconfig .profile 
$ cat .gitconfig 
[user] 
    name = yourusername 
+0

谢谢,但这是我所尝试过的,但没有奏效。我得到了'错误:无法锁定配置文件/ home/ /.gitconfig:权限被拒绝' – patriques

+0

中写道我的问题解决方案在上面,看看是否感兴趣,谢谢你的合作和你的建议。 – patriques

1

试试这个,如果这对你的作品

mkdir ~/.git 
git config --global user.name= <name> 
+0

我的问题解决方案在上面,看看是否有兴趣,谢谢你的合作和你的建议。 – patriques