Test with Unset Email
In this step, we'll see what happens when Git doesn't have a user.email
configured at the local level, but does have one at the global level. This reinforces the concept of configuration precedence.
First, let's make sure we are in the my-time-machine
directory:
cd ~/project/my-time-machine
Now, we will unset the local user.email
configuration using the --unset
flag:
git config --unset user.email
This command removes the user.email
setting specifically from the local repository configuration. It won't affect the global configuration.
Let's verify that the local configuration is gone by trying to retrieve it:
git config --local user.email
You should see an error message indicating that the configuration key is not found at the local level:
error: key 'user.email' not found
Now, let's check the user.email
again without any flags while still in the my-time-machine
directory:
git config user.email
What do you expect to see? Since the local configuration is unset, Git should fall back to the global configuration.
[email protected]
As expected, it now shows the global email address again! This confirms that when a local configuration is not present, Git uses the global configuration.
This step demonstrates the hierarchy of Git configurations. Git looks for settings at the local level first. If it doesn't find them there, it looks at the global level, and then the system level. This allows for flexible configuration depending on your needs for different projects.