Use -c option along with git-commit to override any previous configuration. It will not touch your global/project configuration. For example, to override name and email:
git -c user.name='My Name' -c user.email='[email protected]' commit -m "Custom message"
However, if you intend to keep it as an additional setting, I would suggest to use an alias. Edit your ~/.gitconfig
file and append a new alias for each non-default user and email.
[user]
name = My Name
email = [email protected]
[alias]
commit-x = -c user.name='My X Name' -c user.email='[email protected]' commit
commit-y = -c user.name='My Y Name' -c user.email='[email protected]' commit
commit-z = -c user.name='My Z Name' -c user.email='[email protected]' commit
Alias will be applied globally. Test it.
git commit -m "Custom message with committer and author My Name <[email protected]>"
git commit-x -m "Custom message with committer and author My X Name <[email protected]>"
git commit-y -m "Custom message with committer and author My Y Name <[email protected]>"
git commit-z -m "Custom message with committer and author My Z Name <[email protected]>"