Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
v2 of Gist for blog post 'Revised Configuration of Git for Windows on a Corporate Network with Vagrant'. Easily turn proxy-related settings on and off for Git for Windows. 1) Add these functions to your ~\.bashrc file, 2) Change PROXY_SERVER, and PORT default values, 3) Open new Git Bash interactive shell window and execute function before using…
# configure proxy for git while on corporate network
function proxy_on(){
# assumes $USERDOMAIN, $USERNAME, $USERDNSDOMAIN
# are existing Windows system-level environment variables
# assumes $PASSWORD, $PROXY_SERVER, $PROXY_PORT
# are existing Windows current user-level environment variables (your user)
# environment variables are UPPERCASE even in git bash
export HTTP_PROXY="http://$USERNAME:$PASSWORD@$PROXY_SERVER.$USERDNSDOMAIN:$PROXY_PORT"
export HTTPS_PROXY=$HTTP_PROXY
export FTP_PROXY=$HTTP_PROXY
export SOCKS_PROXY=$HTTP_PROXY
export NO_PROXY="localhost,127.0.0.1,$USERDNSDOMAIN"
# optional for debugging
export GIT_CURL_VERBOSE=1
# optional Self Signed SSL certs and
# internal CA certificate in an corporate environment
export GIT_SSL_NO_VERIFY=1
env | grep -e _PROXY -e GIT_ | sort
echo -e "\nProxy-related environment variables set."
}
# remove proxy settings when off corporate network
function proxy_off(){
variables=( \
"HTTP_PROXY" "HTTPS_PROXY" "FTP_PROXY" "SOCKS_PROXY" \
"NO_PROXY" "GIT_CURL_VERBOSE" "GIT_SSL_NO_VERIFY" \
)
for i in "${variables[@]}"
do
unset $i
done
env | grep -e _PROXY -e GIT_ | sort
echo -e "\nProxy-related environment variables removed."
}
# if you are always behind a proxy uncomment below
#proxy_on
# increase verbosity of Vagrant output
export VAGRANT_LOG=INFO
@garystafford

This comment has been minimized.

Copy link
Owner Author

commented Dec 31, 2013

v2 Version Changes

  • PASSWORD, PROXY_SERVER, PROXY_PORT moved to Windows user-level environment variables
  • DOMAIN environment variable removed. Problems with Vagrant using DOMAIN in URI! Use fqdn for PROXY, instead: http://username:password @ proxy.domain.tld:port
@dhergert

This comment has been minimized.

Copy link

commented Mar 16, 2015

Gary - what is the benefit of setting these in environmental variables versus your .gitconfig?

git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080

git config --global --unset http.proxy
git config --global --unset https.proxy

[http]
    sslVerify = false
    proxy = username:password@proxy:80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.