Normally people don’t face problem in connecting GitHub and committing code to their repositories. However I work in a environment with proxy based supervision being enabled across entire domain, which makes things little complex for a coder. Fortunately some organizational proxy provides access to GitHub and it’s sub-domains. Given this I started thinking of using GitHub as my version controlling system.
There are broadly two kinds of network restrictions usual organization or companies impose. These are
- Proxy : An internal proxy server is being used to block desired websites. Lot of organization, specifically those who can afford to employ external vendor, use Automatic Proxy Configuration Script [pac file].
- VPN : Usually all network traffic tunneled though VPN making things little easier provided target site is open under VPN.
May of us may use proxy script (rather provided by the organisation where one belongs). Here in this technical document I’ll discuss ways to use this proxy with different services that codes may require.
Getting the Proxy
First I’ll show how one can get proxy configuration script [usually which gives different proxy based on site one try to access] and parse it to get a usable proxy. By means a usable proxy I mean either of HTTP or HTTPS or SOCKS proxy.
Steps to get usual proxy from PAC file:-
- In windows open “Internet Options” [from internet explorer setting and then connection tab] [or search for proxy in Windows 8 or later]

- Get the script
In my case it’s like http://xxx.xx.xx.xx:8443/proxypac.pac [IP hidden].
- Open this in normal browser. This will download the pac file.
- Open that pac file in normal text editor. [If you have Notepad++ use language as JavaScript which will enable you more readability] And then figure out what will be actual proxy for a specific website. If you don’t want to see at huge code [though it’s simpler as per my view] you can use PAC parser [online version or through coding library]. [Personally I prefer online method [unless it’s blocked or the service is unavailable]. Just paste the code and desired website and get the proxy.]
Using the Proxy
Now you have a usual proxy [in my case it’s http proxy like 172.xx.x.xx:3128] for GitHub obtained from above method. Let’s proceed to using it. Here in my attempts section I described the path in which I arrived in the final conclusion, which may be skipped and final implementation alone can be studied.
Attempts to use GitHub with R-Studio
I started with R-Studio official guide and a really helpful r-bloggers post in my R-studio server setup [base OS was CentOS 6.5]. I had access to other two systems at a same time [through remote access and physical access] [one is my local work PC which also governed under same proxy and another my Home PC without any proxy boundaries]. I tried instruction set given in above mentioned documents in my home PC and it worked like a charm. But in server I faced first blockage in DNS settings. Well when you use ssh for committing to GitHub you need to have github.com resolved correctly in local terminal [OMG what is all these, you might be thinking. Don’t worry it’s a basic networking concept most of us don’t need to know as it’s generally meant for network support guys. But being a technologically not handicapped I always prefer to resolve system level requirement by myself. I’ll give you a basic idea about the concept. ].
In Linux server you can check the “host-name resolve configuration” by issuing following command in terminal
cat /etc/resolv.conf
Usually you’ll see something like this
# Generated by NetworkManager
search your_domain.com
nameserver 172.xxx.xxx.xxx
Now the IP given after nameserver is the IP where name resolution happens. Means actually global physical IP of any website is being retrieved from a directory kind of service hosted in that IP. As for example when you issue following command
ping github.com
it goes to the nameserver and retrieves the IP for github.com. Here is and example output in windows [with no proxy limitations]

Now here in this organization the nameserver does not even have a entry for github.com. Which means when you run “ping github.com” in proxy enabled system it is not able to locate actual IP address corresponding to github.com.
So I thought of using proxy to resolve the names [alphabetical address of a IP, here it’s github.com we are trying to resolve]. I got one software in windows named Proxifier which does the job for you. But I did not get anything ready made in Linux.
Then I researched a bit for alternatives to DNS over proxy. After a short research I thought why don’t I try to host a nameserver locally. Well that gave me some idea which may be useful for someone. I got several links for this topic. Out of all these links one can consult blog in howtoforge.com and in digitalocean.com. I started reading these documents but I felt that it’s little too much for simple requirement to be fulfilled.
Then I tried to seek other ways to get things going. Then I got an idea from one “Stack-Overflow question answer topic” where someone suggested to use http commit instead of ssh commit. This gave a a light as http requests will pass through curl like tools which will in tern access proxy server and hence there is a chance that the name resolution problem will not occur.
This indeed worked in one of my work PC which runs on Windows OS. But unfortunately it did not run on my Linux server.
I started finding the root cause of the problem. After a helpful topic from GitHub, I got the idea that I need to upgrade the git-shell in order to make the commit work smooth over http. The GitHub link leaded me towards Git Download Page, where I got the information about IUS Community Project. But unfortunately after installing IUS repository when I issue command like
yum install git
it did not update git to desired version of git-shell. So I Googled a bit for another solution which gave me a nice blog on the same topic. But unfortunately repoforge.org was down. So I left with only one solution that is to compile git from source.
Finally I am able to update the version of git by compiling it from the source. I had followed a really detailed blog on this [though I had to remove old version of git]. And after the same I was able to commit in GitHub from R-Studio. The gist and step by step instruction is given in next section. I guess this method will work in all the cases even if the proxy is such a way that DNS can resolve the name. It’s always better to have a generic method which works in most of the scenarios.
Use GitHub with R-Studio over Proxy
Here are the steps to be followed in Linux environment [with few minor alteration same can be adopted in windows. Windows git up-gradation is not a major problem and can be done easily.]
- Step 1:Firstly in console remove the git if the version of the git is below 1.7.10
To check git version run
git --version
To remove use something like [I’m in CentOS. If you are in different OS check the uninstall command]
yum remove git
- Step 2: Follow this post. Only while checking the version use above command instead of “git -version” [two “-” before version is required]
- Step 3:Set global parameters as follows [these commands to run in console]
Set your username and e-mail id for GitHub commits
git config --global user.email "nil.gayen@gmail.com"
git config --global user.name "bedantaguru"
Set proxy [as detected from above section]
git config --global http.proxy http://172.xx.x.xx:3128
git config --global core.gitproxy "git-proxy"
Now we are all setup to follow tutorials like r-bloggers.com Blog.
- Step 4: Now one can follow this blog [it is indeed a nice blog and well documented process flow]. Only when the blog writer suggested to use “git config remote.origin.url”, same can be ignored. As I have seen commit works without that with the latest git-shell which was compiled in Step 2. Remember you have to commit at least once locally. here is an example of what I did

- Step 5: When you use http commit method you’ll get promoted with username and password even if you have set that on global level. Provide these details for authentication.
After this you’ll be able to complete the commit. here is a screen shot of the same.
In the console

In the browser

This concludes the steps involved in using GitHub web account in R-Studio. It’s required when you want to host your code in GitHub. If you are only interested in local version control perhaps you don’t need anything of these.
Download Links:
- Git for Windows
- GitHub Desktop
- Git Source
Reference:
- GitHub Official Support Page : Using SSH over the HTTPS port
- R-Studio Official Blog : Version Control with Git and SVN
- Really Great r-bloggers.com Blog.
- Linux: Setup as DNS Client / Name Server IP Address
- Stack Overflow Questions : Q1 Q2 Q3