Skip to content

Instantly share code, notes, and snippets.

@xphere
Last active November 16, 2021 08:39
Show Gist options
  • Save xphere/835563e8ba5352ad31465aba19907bb7 to your computer and use it in GitHub Desktop.
Save xphere/835563e8ba5352ad31465aba19907bb7 to your computer and use it in GitHub Desktop.
How to call git with default configuration?
#!/bin/bash
# git gets configuration from three main places: current repository, current user, system-wide
# Those can be skipped by changing the following environment variables
# PREFIX= HOME= GIT_CONFIG_NOSYSTEM=
# NOTE: Current repository can't be overriden
# But git requires at least the author and committer name/email
# Those must be setup with the following environment variables
# GIT_AUTHOR_NAME= GIT_AUTHOR_EMAIL= GIT_COMMITTER_NAME= GIT_COMMITTER_EMAIL=
# Thus the call will be something like this
EMAIL="[email protected]"
NAME="Name Surname"
export GIT_AUTHOR_NAME="$NAME"
export GIT_AUTHOR_EMAIL="$EMAIL"
export GIT_COMMITTER_NAME="$NAME"
export GIT_COMMITTER_EMAIL="$EMAIL"
export GIT_CONFIG_NOSYSTEM=1
PREFIX=/tmp HOME=/tmp git "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment