LoginSignup
14
12

More than 5 years have passed since last update.

CentOS6 の git で error: 401

Last updated at Posted at 2016-04-16

事象

CentOS6.7でgit cloneしようとすると401が発生します。

error: The requested URL returned error: 401 Unauthorized while accessing https://git.example.org/git/basic

fatal: HTTP request failed

暫定回避策

ユーザ名(とパスワード)をURLに含めると回避できます。

$ git clone https://_user:_pass@git.example.org/git/basic

原因

1.7.10以上でないと古いため発生するようです。

$ git --version
git version 1.7.1

There's no minimum Git version necessary to interact with GitHub, but we've found version 1.7.10 to be a comfortable stable version that's available on many platforms. You can always download the latest version on the Git website.

最新版の導入

ダウンロード

Git - DownloadsGit source repository から Releases · git/git で最新版を取得します。

$ cd /usr/local/src/
$ sudo curl -L -O https://github.com/git/git/archive/v2.8.1.tar.gz

インストール

Git - Gitのインストールソースからのインストール を参考にインストールを行います。

公式手順には無いですが、perl-ExtUtils-MakeMaker も必要です。

# 前提パッケージインストール
$ sudo yum install curl-devel expat-devel gettext-devel   openssl-devel zlib-devel perl-ExtUtils-MakeMaker
# コンパイル
$ cd /usr/local/src/
$ sudo tar -zxvf v2.8.1.tar.gz
$ cd git-2.8.1/
$ sudo make prefix=/usr/local all
$ sudo make prefix=/usr/local install

最新版を使用できることを確認します。

$ . ~/.bash_profile
$ which git
/usr/local/bin/git
$ git --version
git version 2.8.1

最新版gitでリポジトリ操作の確認

URLにユーザ名(とパスワード)を含めなくとも実行できるようになります。

$ git clone https://git.example.org/git/basic
Username for 'https://git.example.org':
Password for 'https://_user@git.example.org':
14
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
12