SourceTreeを使って、DevOpsにプッシュしようとしたら、急にできなくなってしまったので、その解決法のメモ書き
-
エラー内容
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks push -v origin feature/addMixDisease:feature/addMixDisease fatal: Cannot determine the organization name for this 'dev.azure.com' remote URL. Ensure the `credential.useHttpPath` configuration value is set, or set the organization name as the user in the remote URL '{org}@dev.azure.com'. fatal: Cannot determine the organization name for this 'dev.azure.com' remote URL. Ensure the `credential.useHttpPath` configuration value is set, or set the organization name as the user in the remote URL '{org}@dev.azure.com'. fatal: Authentication failed for 'https://dev.azure.com/hoge' Pushing to https://dev.azure.com/hoge エラー終了しました。エラーの内容は上記をご覧ください。
-
試したこと
- SourceTreeを閉じる
- コマンドプロンプトで以下のコマンドを実行
git config --global credential.useHttpPath true
- SourceTreeを開いてプッシュ
-
GPTに聞いた
credential.useHttpPath true を設定すると? この設定を有効にすると、Gitは URLのパスも認証情報のキーとして扱う ようになる。 つまり、認証情報をキャッシュするときに リポジトリごと に記録するようになるんや。 ✅ 設定前(デフォルト) dev.azure.com だけを認証情報として保存 組織やリポジトリが異なっても同じ認証情報を使おうとする 結果的に 組織名が見つからず認証エラー になることがある ✅ 設定後(true) https://dev.azure.com/my-org/my-project/_git/my-repo のように フルパスでキャッシュ 各リポジトリで 正しい認証情報を使う Azure DevOpsでの認証エラーを防ぐ
複数組織を追加している場合に正しいパスをキャッシュするような設定ってことかな。