Skip to content

Instantly share code, notes, and snippets.

@putermancer
Created February 28, 2011 18:24
Show Gist options
  • Save putermancer/847755 to your computer and use it in GitHub Desktop.
Save putermancer/847755 to your computer and use it in GitHub Desktop.
git + gitolite shell access, user-based
#!/bin/bash
shift # get rid of -c
# if no commands, just open a shell
if [[ $# -eq 0 ]]; then
/bin/bash -l
# if the first arg is a git- command, that means it is something like git-push, etc... so forward it
elif [[ $1 == git-* ]]; then
ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no git@localhost $*
# if the first arg is SET_ENV_ONLY, we sourced this file in order to set up the gitolite function
elif [[ $1 == "SET_ENV_ONLY" ]]; then
gitolite () {
ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no git@localhost $*
}
# if there is at least one non-git command, source this file in a new shell and create the 'gitolite' function
else
/bin/bash -c "source $0 shiftme SET_ENV_ONLY; $*"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment