ablog

不器用で落着きのない技術者のメモ

2段階認証設定後に GitHub に push すると "fatal: Authentication failed for" と怒られる

事象

  • GitHub で2段階認証設定後に push すると "fatal: Authentication failed for" と怒られる。
$ git push -u origin master
Username for 'https://github.com': yoheia
[core]
Password for 'https://yoheia@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/yoheia/yoheia-portfolio.git/'

解決策

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = git@github.com:yoheia/yoheia-portfolio.git ★
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[submodule "public"]
        url = git@github.com:yoheia/yoheia.github.io.git ★
        active = true
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
        worktree = ../../../public
[remote "origin"]
        url = git@github.com:yoheia/yoheia.github.io.git ★
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

*1:yoheia-portfolio はリポジトリのベースディレクト