Need help with gitconfig, please


#1

I haven’t been able to get git config —get user.name to return my full name. Typing git config —get user.name returns my first name only, preceded by a double quote, like this “Mark

How can I get git config — get.user name to return my full name and not just a quote and my first name?

I’ve copied and pasted as well as typed ‘git config --global user.name “Mark LastName” ‘ into the terminal and always get the same result .

Thanks in advance for any help!


#2

Hi M_June.

try to re-configure the user.name using command:

git config --global user.name “User Name”

then you can retrieve it by:
git config --global user.name
or
git config --get user.name

both options should work fine.


#3

Hi Ghassan,

Thanks for your reply.

I’ve already done what you suggest and I always get the same result. At the time I first posted my question, I had accidentally forgotten to install homebrew, git, Heroku and Ruby. I’ve now installed all those programs.

By entering `git config --list’, I currently get the following values:

credential.helper=osxkeychain
user.email=“SomeOne@example.ca”
user.name=“Mark
user.name=“Mark
user.name=“Mark
user.name=“Mark
user.name=“Mark
color.ui=auto

It looks likegit config --global user.name “User Name”` just adds additional, incomplete values for user.name and doesn’t overwrite the old values.

How can I delete the multiple instances of user.name=“Mark and replace them with just one value for global user.name? How can I get git config to accept both my first and last names?

Thanks again


#4

Hey,

I was able to edit the .gitconfig file in visual studio code, maybe you can take a look at it and edit it using a text editor. looks like you are using a mac - i don’t know how.

The file is supposedly located in $HOME/.gitconfig in all platforms.


#5

Ok,thanks. I will try


#6

Hello all,

I tried editing .gitconfig with a text editor and it has created additional problems. Here’s what happened:

In my text editor, I deleted all but one instance of user.name=“Mark
In my text editor, I changed user.name=“Mark to user.name=“Mark Lastname”
In Terminal, I entered ‘git config --get user.name’
It returned the following error fatal: bad config line 3 in file /Users/mnh/.gitconfig
In Terminal, I entered git config --global user.name “Mark Lastname”
Again, it returned fatal: bad config line 3 in file /Users/mnh/.gitconfig.

Does anyone have any idea about how to solve this?

Thanks!


#7

can you copy and paste the contents of you file. we can try to determine the cause of the error.


#8

Sure.

[user]
	email = “mLastname@example.ca”
	name = “Mark Lastname"
	
[color]
	ui = auto

I don’t know why some of the text show up red. In my text editor, it was black.


#9

are the quotation marks in your file?


#10

Yes.


#11

ok lets remove the quotation marks.
also remove the empty line before [color]
your file should look like this:

[user]
email = mLastname@example.ca
name = Mark Lastname
[color]
ui = auto


#12

Thanks so much, Ghassan! I removed the quotes and empty line and it works. Thanks for taking the time and have a good weekend