2018/02/15(Thr)git for windows (mingw)のパスワードは .netrc ではなく _netrc

はてブ数 2018/02/15 6:36 つーさ
記事タイトルがすべて。本文は蛇足。

ローカルに作ったgitリポジトリをGoogle Cloud ソース レポジトリにpushしよう。

マニュアル
https://cloud.google.com/source-repositories/docs/adding-repositories-as-remotes

git for windows 環境で、(+Sourcetreeだけど)
Invalid authentication credentials.
マニュアルの通り、gcloudコマンドでリポジトリは作れる。
$ gcloud source repos create my-awesome-project
で、pushしてみるも、credential helperがうまく呼び出せていないのかなんなのか、うまくいかない。
$ git config credential.helper gcloud.cmd
$ git remote add google https://source.developers.google.com/p/nantoka-kantoka-123456/r/my-awesome-project
$ git push --set-upstream google develop

Invalid authentication credentials.

Please generate a new identifier:
  https://source.developers.google.com/auth/start?scopes=https://www.googleapis.com/auth/cloud-platform
言われたとおりのURLにアクセスすると、オフラインアクセス用のIDとパスワードが発行される。
なになに、 .netrc を作って、中に貼り付けておけ と。

で、書いてあるとおりに、 $HOME/.netrc を作って、パスワードを書いてみたが、やはり結果は同じ。

うーん……????
そもそも、git for windows の .netrc って置き場所ここでいいんか?
悩むことしばし。調べることしばし。

Git - How to use .netrc file on windows to save user and password
https://stackoverflow.com/questions/6031214/git-how-to-use-netrc-file-on-windows-to-save-user-and-password

なんと、おくべきファイルの名前は .netrc ではなく _netrc であった。

ファイル名を .netrc から _netrc に変更してから、もう一度 git push したらうまくいきました。

あはぁ。

windows で dot ファイルを避ける文化、逆に混乱するからやめてほしす……。