Last active
August 29, 2015 14:03
-
-
Save gre/11da8bd3e974ee480878 to your computer and use it in GitHub Desktop.
resolve git config contextually (find a .gitconfig in the PWD tree)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Put this script in ~/bin/git.sh and `chmod +x` it | |
# in your .bash_profile add: alias git=$HOME/bin/git.sh | |
###### DO NOT USE IT ##### | |
##### it doesn't seem to work properly... git commit still put the wrong git config even if git config say something else ###### | |
function upsearch () { | |
slashes=${PWD//[^\/]/} | |
directory="$PWD" | |
for (( n=${#slashes}; n>0; --n )) | |
do | |
test -e "$directory/$1" && echo "$directory/$1" && return | |
directory="$directory/.." | |
done | |
} | |
GIT_CONFIG=`upsearch .gitconfig` git $* | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment