Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Git Basics Getting Started With Git Committing Changes

Global flag -- meaning

When he changes the username using git config --global is global referring to every single repo on the local machine?

2 Answers

Stone Preston
Stone Preston
42,016 Points

according to the git documentation

Git comes with a tool called git config that lets you get and set configuration variables that control all aspects of how Git looks and operates. These variables can be stored in three different places:

/etc/gitconfig file: Contains values for every user on the system and all their repositories. If you pass the option --system to git config, it reads and writes from this file specifically.

~/.gitconfig or ~/.config/git/config file: Specific to your user. You can make Git read and write to this file specifically by passing the --global option.

config file in the Git directory (that is, .git/config) of whatever repository you’re currently using: Specific to that single repository.

As you can see, there are 3 levels of configuration. System, user, and repo.

--global is global referring to every single repo on the local machine?

the docs state

~/.gitconfig or ~/.config/git/config file: Specific to your user. You can make Git read and write to this file specifically by passing the --global option.

so passing in --global configures git for the user, not the entire machine

I have posted my .gitconfig file below. This is in my root. You can add aliases for shorter commands and styling output.

So when you do that global command, it's adding it to this file.

P.S. You can paste this into your .gitconfig file and it will work. Granted you add your username and email.

[user]
  name = YOUR_USER_NAME
  email = YOUR_EMAIL
[color]
  ui = always
[alias]
  s = status
  p = push origin master
  g = pull
  c = commit -m
  a = add -A
  co = !git checkout -b
  b = branch
  rh = reset -head
  st = status
  d = !git add -A && git commit -m
  hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
[push]
  default = simple
[filter "media"]
    required = true
    clean = git media clean %f
    smudge = git media smudge %f
[format]
  pretty = \"%C(yellow)%h%Cred%d%Creset - %C(cyan)%an %Creset: %s %Cgreen(%cr)\"