4

The Cliff's Notes of my original issue is that I have a thesis project repo hosted on GitHub that I'm using multiple machines to access for both reading and writing to the repo. I have my home desktop, my laptop, my professor is using the repo on his machine, and we have our "production" server. We've been using this repo with no issues on our personal machines, via Win7, Win8.1, and Ubuntu 14.04. On all of these systems we're using the following remote URL:

https://github.com/[my-user-name]/thesis.git

...and it works perfectly for pulling and pushing against our repo. However, on the production server, using CentOS 6.x (not sure if that matters) we were getting an error 403 Forbidden, with no opportunity to even try providing a username or password. After troubleshooting this for some time (as a total n00b) I finally discovered that on the CentOS machine only I have to use the remote URL:

https://[my-user-name]@github.com/[my-user-name]/thesis.git

Why would this be the case on only one of our machines?

Update:

VonC's answer below was helpful in getting an understanding of the root of the problem. My Git version on CentOS 6.x is way behind the current version, despite the fact yum update reports it being up-to-date.

The CentOS repos are known to lag behind the most up-to-date packages. Using Git as my example, the most up-to-date version of Git I can get with the CentOS 6 base repository is 1.7.1 which is way, way behind the real current version of Git. I have tried a plethora of solutions including those listed in VonC's helpful answer below such as using the rpmforge repositories to override base and install newer versions of Git, as well as others not listed here, all to no avail. My next step is to try building Git from source, and I will report the results if anything comes of it.

Steverino
  • 2,099
  • 6
  • 26
  • 50

2 Answers2

3

As mentioned in GitHub help page "HTTPS cloning errors", this is because your CentOS 6.x has an old git version. (type git --version to confirm)

If you can upgrade git there, you won't need to attach your username to the url.
If you cannot upgrade, change the remote url to add your username is indeed a workaround.

git remote set-url origin https://yourusername@github.com/user/repo.git

You can also try to add your username for any github url:

git config --global credential.https://github.com.username YOUR_USERNAME

But if git is too old, that last command might not even be supported.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I had checked that Git was updated using `yum update` ... it turns out the CentOS repos do not include up-to-date versions (of a lot of applications) so `yum` said Git was up-to-date even though it's many versions behind. In short, I assume your answer is correct (the workaround does work) but after 2hrs of repo updates and workarounds it seems the only way this will work is by building Git from source, which I'll have to try another time. – Steverino Mar 12 '16 at 19:40
  • Thanks, I did try following the answers there, as well as 3 or 4 other SO threads, and 3 or 4 other tutorials hosted by other sites specializing in CentOS and/or Git and/or RPMForge, all to no avail. I will try building from source later and verify that it works, but for now the workaround of adding my account name to the remote URL is good enough for my purposes. :) – Steverino Mar 12 '16 at 19:56
  • @fts_acer OK, I hope you'll manage to build a more recent version of git. – VonC Mar 12 '16 at 19:58
  • I've struggled with this issue for the better half of the day but have not made progress. Sharing my own experience here given this is the most relevant thread I've found. On Centos 7, `yum install git` gives me 1.8.3.1 which does not require my username within the remote url. On Centos 6.7, `yum install git` results in 1.7.1.4 which exhibits the previously discussed behavior. What's troubling is I've successfully built multiple versions of git using source from [kernal.org](https://www.kernel.org/pub/software/scm/git/). On Centos 6.7, I'm still hitting this problem using git 1.8 and 2.9 – jgrump2012 Aug 17 '16 at 21:58
  • @jgrump2012 could you try and install git from sources? (https://www.digitalocean.com/community/tutorials/how-to-install-git-on-centos-7) – VonC Aug 18 '16 at 13:36
  • @VonC Thanks for the additional tutorial. `yum groupinstall "Development Tools"` simplified my environment configuration across more machines. Grabbing source directly from github (specifically, 1.8.3.1) and working on Centos 6.7, `libcurl-devel` was still required to resolve this specific problem. I built 2 times. First with only `libcurl` installed. Attempting to push to a remote url which did not include userid failed and never prompted for userid/password. Rebuilding the same source with `libcurl-devel` would result in user/pw prompting. – jgrump2012 Aug 18 '16 at 16:38
2

Providing an additional answer w/ the goal of reducing other's trouble.

Building from source isn't as hard as it sounds. No need to describe these steps here. Instead look at:

If wanting a specific git version, look to:

The installation guides will note package requisites. In my experience, the following packages were needed but not discussed:

yum install gettext asciidoc xmlto # 'make doc' requirements
yum install libcurl-devel 

libcurl-devel finally solved userid/password prompting problem. 1.8, 1.9, and 2.9 all built fine w/out libcurl-devel however I was unable to push to a http remote url which did not contain my userid. With libcurl-devel, user/pw prompting occurs.

While I'm here, I think it's also worth pointing out related posts I found:

Community
  • 1
  • 1
jgrump2012
  • 397
  • 3
  • 11