I follow the steps below to access git respositories from behind a corporate proxy. This method works for git repositories using git URLs like "git://something.git"; for git repositories using http URLs like "http://something.git" use the accepted answer for this link instead.
This version uses corkscrew and sets a username and password required by the proxy.
Install corkscrew (Ubuntu)
sudo apt-get install corkscrew
Create credentials file containing your proxy username and password
echo "username:password" > ~/.corkscrew-auth
In my case the credentials look like this
domain\username:password
Secure auth file
chmod 600 ~/.corkscrew-auth
Create corkscrew wrapper script ~/scripts/corkscrew.wrapper
#!/bin/sh
exec corkscrew PROXY_IP_ADDRESS PROXY_PORT $* ~/.corkscrew-auth
Make the script executable
chmod +x ~/scripts/corkscrew.wrapper
Configure git
git config --global core.gitproxy ~/scripts/corkscrew.wrapper
Test if you can clone a repository
git init
git clone git://SOME_GIT_REPOSITORY_ADDRESS
In case you want to clean the git configuration you just made
git config --global --unset core.gitproxy