Configure Git
Git signs every snapshot with a name and an email. You tell Git yours once, and it remembers them.
Set your name
The first command prints nothing. The second reads the name back.
$ git config --global user.name "Alex Learner"
$ git config user.nameSet your email
The same shape sets the email.
$ git config --global user.email "alex@example.com"
$ git config user.emailSee all settings
This list comes from the course machine. Yours will look close, with your own name and email.
$ git config --global init.defaultBranch main
$ git config --global core.editor true
$ git config --listExample
$ git config --global user.name "Alex Learner"
$ git config --global user.email "alex@example.com"
$ git config --listKey points
- Every commit carries your name.
- Git asks for the name once, before the first commit.
- The name can be your real name or a nickname.
- The email is how other people reach you.
- Both live in Git’s settings, not in any project.
- Change them any time with the same commands.
- The list command prints every setting Git holds.
- Git calls a line of work a branch. The first branch is called main.
- Git sometimes opens a text editor to ask for a message. This course sets the editor so it never waits for one.
Here, two commands set the name and email. The list command prints them back. The list also shows two settings the course set for this machine: the first branch is called main, and the editor is set so Git never waits for one.
Note
Use an email you are happy to share. Commits can travel to other people.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does Git attach to every commit?