Skip to content

Instantly share code, notes, and snippets.

@yogeek
Last active March 14, 2019 10:03
Show Gist options
  • Save yogeek/b981bb0e4b9e812f0985a148c5f3b005 to your computer and use it in GitHub Desktop.
Save yogeek/b981bb0e4b9e812f0985a148c5f3b005 to your computer and use it in GitHub Desktop.
Script for local gitconfig for github project
function github-conf() {
# Are we in a GIT repo ?
git rev-parse --is-inside-work-tree > /dev/null 2>&1
if [[ "$?" != "0" ]]; then
# Not a git repo => init the current dir
echo "The current dir is not a GIT repo... Let's init it !"
REPO_NAME=$(basename "$PWD")
GITHUB_REPO="https://github.com/yogeek/${REPO_NAME}.git"
git init
git remote add origin $GITHUB_REPO
else
# Already a git repo
GITHUB_REPO=$(git config remote.origin.url)
fi
echo "This will configure this directory with your personal Github config for ${GITHUB_REPO}..."
# User info
git config user.name "Guillaume Dupin"
git config user.email [email protected]
# GPG key
echo "Retrieving GPG key..."
GPG_KEY=$(gpg --list-secret-keys --with-colons [email protected] 2> /dev/null | grep '^sec:' | cut --delimiter ':' --fields 5)
echo "GPG Key found : $GPG_KEY"
git config user.signingkey $GPG_KEY
git config commit.gpgsign true
# Set remote
echo ""
echo "---------------------------"
echo "Result :"
echo "---------------------------"
git config --local --list
echo ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment