2013-07-28 67 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