Install git username and email without using .gitconfig?

I have a dotfiles repository for macOS that contains a file .gitconfig. I would like to keep usernameit emailseparate from this file so that these variables are never executed as part of my public dotfiles repository.

One approach that I saw is to specify a file with a name .extra, saving it in a directory ~/(referenced in it .bash_profile) and set the Git variables in this file so that they are external to my public repository, i.e. any public changes, which I do for .gitconfigwill not include usernameand email.

The problem is that none of the approaches to setting these values ​​work for me. After each attempt, I get the following message:

Your name and email address have been automatically configured for your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly:

git config --global user.name "Your Name"

git config --global user.email you@example.com

After that, you can fix the identifier used for this commit with:

git commit --amend --reset-author

My .extrafile has the following:

GIT_AUTHOR_NAME="First Last"

GIT_COMMITTER_NAME="First Last"

EMAIL=email@example.com

I tried various approaches using these variables and others, and also included and excluded quotes and even prefixing these strings with export. Lose a little!

+4
source share
2 answers

I understood the solution:

dotfiles .gitconfig :

[user] # These values are set in ~/.gitconfig_local

[include] path = ~/.gitconfig_local

~/ .gitconfig_local , .gitconfig. :

[user] name = First Last email = email@example.com

, [include] "" , , , , . .gitconfig, , .., - .

+5

: --global git config:

# from inside your repo :
git config user.name "Your Name"
git config user.email you@example.com

.git/config ( ) .

git (, ,...)

: , , ,

+2

Source: https://habr.com/ru/post/1671238/


All Articles