Skip to content

Instantly share code, notes, and snippets.

@gregtzar
Created December 27, 2012 21:51
Show Gist options
  • Select an option

  • Save gregtzar/4392368 to your computer and use it in GitHub Desktop.

Select an option

Save gregtzar/4392368 to your computer and use it in GitHub Desktop.
Clone a github repo from bash via http. Uses http auth and encodes username/password.
uname='BOBDOBBS'
pwd='3n*90!23nl1'
sedEncode='s/%/%25/g;s/ /%20/g;s/ /%09/g;s/!/%21/g;s/"/%22/g;s/#/%23/g;s/\$/%24/g;s/\&/%26/g;s/'\''/%27/g;s/(/%28/g;s/)/%29/g;s/\*/%2a/g;s/+/%2b/g;s/,/%2c/g;s/-/%2d/g;s/\./%2e/g;s/\//%2f/g;s/:/%3a/g;s/;/%3b/g;s//%3e/g;s/?/%3f/g;s/@/%40/g;s/\[/%5b/g;s/\\/%5c/g;s/\]/%5d/g;s/\^/%5e/g;s/_/%5f/g;s/`/%60/g;s/{/%7b/g;s/|/%7c/g;s/}/%7d/g;s/~/%7e/g;s/ /%09/g'
encodedUname=$(echo "$uname" | sed "$sedEncode")
encodedPwd=$(echo "$pwd" | sed "$sedEncode")
repoStr="http://$encodedUname:$encodedPwd@github.com/fnord/five-tons-of-flax.git"
cd ~/
git clone "$repoStr"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment