LoginSignup
6

More than 5 years have passed since last update.

Bitbucketからの"git pull"に失敗する

Last updated at Posted at 2017-07-14

git pull したらこんなエラーが発生した

remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
fatal: Authentication failed for 'https://XXXXXXXX@bitbucket.org/XXXXX/XXXXX.git/'

原因

Bitbuckethaはユーザー名を変更すると、アカウント名でログインできなくなり、メールアドレスでしかログインできなくなります。
このブランチはユーザー名変更前にgit cloneしていたので、当時のログイン情報(アカウント名)でアクセスしていたのが原因でした。

ユーザー名はユーザーが任意に変更できるやつ
アカウント名は最初に発行されて変更できないやつ(Bitbucket内ではフルネームと言われる)
※他の原因の場合もあるので必ずしもこれが原因とは限らないです

対処

git pullした時のアカウント情報を更新して、正しいログイン情報を設定します。

手順1

.git/configから、アカウント名(username@)を削除します

[remote "origin"]
    url = https://username@bitbucket.org/XXXXX/XXXXX.git

[remote "origin"]
    url = https://bitbucket.org/XXXXX/XXXXX.git

手順2

もう一度git pullを実行して認証

このとき、usernameはBitbucketにログインできるものでなければいけません。
Bitbucketでは、ユーザー名を変更するとメールアドレスでしかログインできなくなるので、usernameにはメールアドレスを入力します

$ git pull
Username for 'https://bitbucket.org': XXXXX@example.co.jp    ←メールアドレス!
Password for 'https://XXXXX@example.co.jp@bitbucket.org':

これで、無事git pullができるようになります!

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
6