无法为用户创建gitconfig文件
在创建用户之前,我已经在Linux(debian)系统上以root用户身份安装了git。创建用户后,我尝试运行命令(作为新用户): 但我得到了一个错误:无法为用户创建gitconfig文件,git,Git,在创建用户之前,我已经在Linux(debian)系统上以root用户身份安装了git。创建用户后,我尝试运行命令(作为新用户): 但我得到了一个错误: error: could not lock config file /home/<username>/.gitconfig: Permission denied 它以路径/home/.gitconfig启动我的编辑器。我觉得这真的很奇怪。我试图创建.gitconfig文件,方法是将其创建为sudo,然后将.gitconfig文件从
error: could not lock config file /home/<username>/.gitconfig: Permission denied
它以路径/home/.gitconfig
启动我的编辑器。我觉得这真的很奇怪。我试图创建.gitconfig文件,方法是将其创建为sudo,然后将.gitconfig文件从/root/.gitconfig
移动到/home/.gitconfig
,最后将其移动到我的用户,但这也不起作用。
请帮帮我
编辑: 这个问题与用户对其主目录的权限有关。我只是跑:
sudo chown username:username /home/username
然后它就像usal一样工作。在你变得疯狂之前,只需在
.gitconfig
中手工编辑/插入用户名即可?使用您选择的编辑器打开它,然后继续:
gitconfig摘录自我:
命令行中的用户
名称
是配置中的[user]
+名称=
组合。名称
只是用一个选项卡缩进。安装git
vagrant@precise32:~$ sudo apt-get install git
..设置您的用户
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
…配置git
$ git config --global user.name "yourusername"
$ ls -a
. .. .bash_logout .bashrc .gitconfig .profile
$ cat .gitconfig
[user]
name = yourusername
如果这对你有用,试试这个
mkdir ~/.git
git config --global user.name= <name>
mkdir~/.git
git config--全局用户名=
但问题是它不存在于用户空间中?好的,但是我试着用手做。。。我会回来找你的,谢谢我的问题解决方案在上面,看看是否有兴趣,谢谢你的合作和建议。谢谢,但这是我尝试过的,但不起作用。我得到了“错误:无法锁定配置文件/home/.gitconfig:Permission denied”,如上面的postMy问题解决方案中所述,请查看是否感兴趣,感谢您的合作和建议。我的问题解决方案在上面,请查看是否感兴趣,感谢您的合作和建议。请查看此相关问题。
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
$ git config --global user.name "yourusername"
$ ls -a
. .. .bash_logout .bashrc .gitconfig .profile
$ cat .gitconfig
[user]
name = yourusername
mkdir ~/.git
git config --global user.name= <name>