LoginSignup
2
0
記事投稿キャンペーン 「2024年!初アウトプットをしよう」

[備忘録] gitlabで「remote: HTTP Basic: Access denied...」のエラーが出た時の対処方法

Last updated at Posted at 2024-01-04

こんにちは!!炭酸水ケンタです。
Qiita でずっと記事をかこうと思っていて、ずっと書けなかったのですが、
遂にその時が来たと思い、書いてみました。

gitlab でpush してみたらあれ、、access denied.... なんで??ってなったことありませんか??

エラー文

HTTP basic error ?? basic 認証的なエラー??

remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See https://gitlab.com/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied
fatal: Authentication failed for 'https://gitlab.com/xxxx/xxxx.git/'

これはあれですね!2段階認証にした時に出るエラーです!!
2段階認証にしたらどうもgit push が通らないみたいなんです!

解消法

少し手間ですが、解消法自体はとても簡単です。

① personal access token を発行
select scope の箇所は

  • read_repository
  • write_repository

の二つさえあれば、とりあえずは基本的なgit の操作(=git push)とかができると思います。

② git remote url にaccess token を加える

git remote set-url origin https://oauth2:<access_token>@gitlab.com/ユーザー名/レポジトリ.git
  • <>は抜いてください

これでエラーなくpush できると思います!!

まとめ

git 系のエラーは少し戸惑いましたが、解消が簡単だったので、今回は詰まらずに済みました。エラーの内容も理解するためにこれからもブログを書いて頭の中を整理したいと思います。

参考サイト

2
0
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
2
0