Variables#
This page considers the properties of some of the variables available in the configuration files. Check more in the specific part of the documentation.
Name/email#
There are options that contains information about actors who involved in development. This information will be stored as metadata for each commit. That’s why one of the first issues for git begginer could be configuration of the user.name
which is required by git to create a single commit.
user.name
/user.email
.author.name
/author.email
.commiter.name
/commiter.email
.
In a commit, there are two entities: committer and author. Usually, they are the same person, so if either of them isn’t specified, the field defined for user
will be used.
For example, the following cell creates a temporary repository that will be used as an example.
mkdir /tmp/name_email_git
cd /tmp/name_email_git
git init &> /dev/null
The following cell demonstrates a common issue for new Git users. When attempting their first commit, messages appear indicating that a username and email must be specified.
Note: For the commit
command, the variables GIT_CONFIG_GLOBAL
and GIT_CONFIG_SYSTEM
are specified as empty to prevent git
from using global and system settings defined in the system where the example is executed.
echo "message" > some_file
git add --all
GIT_CONFIG_GLOBAL= GIT_CONFIG_SYSTEM= git commit -a -m test_commit
true
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'f-kobak-distance-desctop@f-kobak-distance-desctop-HP-Pavilion-Laptop-15-eg0xxx.(none)')
The following cell specifies user.name
and user.email
.
git config --local user.name my_user
git config --local user.email mail@mymail.com
Now commit can be performed.
git add --all
git commit -a -m test_commit
[master (root-commit) 469a98c] test_commit
1 file changed, 1 insertion(+)
create mode 100644 some_file
In the commit description, you can find user.name
and user.email
that were specified during configuration.
git log --pretty=full
commit 0ffb610a67d49492f0b217a785f8de6db26cc4c3 (HEAD -> master)
Author: hello <wow@mymail.com>
Commit: hello <wow@mymail.com>
test_commit
Editor#
You can set the editor to be used for editing commit text by using the core.editor
variable. You just have to specify command to invoke editor you would lile to use. For example with command:
git config core.editor vim
You can set vim as a default editor for git
.
As an example, consider setting up a simple script to be used as an editor for git
. The following cell creates the repo we’ll use as an example.
mkdir /tmp/editor_configuration
cd /tmp/editor_configuration
git init &> /dev/null
Here is the creation of the script that would be used as the editor. This script just prints “custom message” to the standard output.
cat << EOF > my_edit.sh
echo
echo "custom message"
EOF
chmod +x my_edit.sh
Here is the procedure for setting this script as a value for the core.editor
variable in the git configuration.
git config --local core.editor /tmp/editor_configuration/my_edit.sh
The following cell attempts to commit to this repository.
git add --all
git commit
true
hint: Waiting for your editor to close the file...
custom message
Aborting commit due to empty commit message.
It actually resulted in an error, but we got “custom message” in the output, which made me sure that the script specified in core.editor
was called.