Skip to content

Instantly share code, notes, and snippets.

@mingchen
Created January 14, 2016 00:28
Show Gist options
  • Save mingchen/992442e928952da59dbd to your computer and use it in GitHub Desktop.
Save mingchen/992442e928952da59dbd to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Author: Ming Chen
#
# Replace git protocol git:// with https:// in .git/config
# This solve this issue when you behind a firewall like a company and your firewall ban git protocol.
#
# Example error form git:
#
# fatal: unable to connect to github.com:
# github.com[0: 192.30.252.130]: errno=Connection refused
#
#
# Usage example: find . -type d -name .git -print -exec git_replace_git_with_https.sh {} \;
#
TMPFILE=/tmp/config.tmp.$$
GITCONFIG=config
if [ -d .git ]; then
GITCONFIG=.git/config
fi
if [ -f $GITCONFIG ]; then
sed 's/url = git:/url = https:/' $GITCONFIG > $TMPFILE
mv $TMPFILE $GITCONFIG
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment