- [Cameron] Hey, Cameron McKenzie here.
@Cameronmcnz on Twitter. I want
to talk about git config list. And specifically
in the context of figuring out how
a particular git property gets assigned its value.
There's this bunch of different config files,
and there's a cascading nature to it.
So sometimes things can get a little bit confusing.
I'm gonna try and clear that up right here.
Now let's see what value.
This git repository says myuser.email addresses.
In order to get that information,
I just say git config--get,
and then the property user.email.
And you can see that
it thinks my email addresses is local@example.com.
Now, that's really weird, because just recently,
I did a git config setting.
And I said, in the system settings,
set the user.email address to be system@example.com.
And you can see that even though I just did that,
if I try and get the username,
it still keeps saying local example.
So you might wanna ask git.
Hey, what are the different values
that are associated with all of the configuration.
In order to do that you say git config--list.
And this will give you a listing of all
of the different properties throughout all of
the different files that have been set.
And you can see right here.
Well, this user.email address is pretty crazy.
You can see that it's got a system scope,
but global scope, a local scope
and a portable scope, as well.
So this is getting pretty nice.
You can see that the user.name property
is set there as well. If you actually want
to see where all of these files are set,
one of the other things you can do
is you can say git config list--show origin.
And now it goes one step further.
Not only shows these properties,
but it shows you all of the different files
in which these properties are set.
So you can see portable is in this program data file,
you can see that the syste.sally is
in the system directory which is the git installation.
You can see that the global setting here
is in the .git config of the user.
And then the email address here is in the local file.
And that's the local repository.
Now, if you want, you can go and edit these files
and change them. So right now it says local@example.com.
If I open up Notepad, and you can see right here,
there's git config that's in the Etsy.
You can see program data is the portable scope.
You can see the global scope here
in the username.git config.
And then here's my local so I can always change
a property. That's been changed right now.
I can head over here, take a look at what it says.
And you can see that this file has now updated and changed.
And you can also see that if I delete this scope here,
and maybe even delete in the owner's folder,
that's my user folder. So that would be my global setting.
And you can see that I've now deleted those files.
I can go back to git and because all this is cascading.
And you can see if I get the email address now,
it no longer says that my email address is my local.
It no longer says that my email address is global,
which was the one that was set in the dot git config,
but it's now saying that it is system@example.
And you can see that system is set over here
at that system level. Anyway,
that gives you an idea of not only how
to list your various guest git config properties,
but also inspect individual ones.
And then if you need to go in edit them
or change them, you can use this command
to see where those files are,
where you would do those edits.
And there you go. That's how git config list works.
And that's how you can figure out how various properties
are getting assign their value.
Now, if you enjoyed that tutorial,
head over to TheServerSide.com.
I'm the editor in chief over here
Lots of stuff on git DevOps
and enterprise software development.
If you want to keep up with my personal antics,
follow me on Twitter @Cameronmcnz and subscribe on YouTube.