以下省略!

タイダルウ(ry ほぼ毎日1記事執筆運動実施中。 ※記事に広告(アフィリエイト)リンクを掲載している場合があります。

Github Pages作ろうといろいろしてたら落とし穴に数回落ちた

Githubレポジトリ作ったことがない俺がGithub Pages作ってみようといろいろしてたのだが、ちょっと苦戦したのでメモしておく。

pushで404

$ git push
fatal: https://github.com/username/repo/info/refs not found: did you run git update-server-info on the server?
$

cloneの時にURLの末尾に.gitがついていなくてもcloneはできるがpushできない。
.git/configのremote "origin"内のurlを弄るかURLに.gitを付けてcloneし直す。
そしてpushしてみるも…(次項に続く

pushで403

$ git push
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/username/repo.git/info/refs
$

今度は403。
いろいろ検索した結果、sshでつなぎに行くようにした。.git/configを開き、remote "origin"内のurlを書き換える。

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = ssh://git@github.com/username/repo.git

そしてpushしようとしたら…(次項に続く

ssh鍵認証

$ git push
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
$

クライアントに鍵が登録されていない感。
ssh-agentをたちあげているのであればGithubに登録したSSH鍵をssh-addで登録しておくか、~/.ssh/configに以下のように書く。IdentityFileは使用する秘密鍵ファイルを指定。

Host github.com
 HostName       github.com
 IdentityFile   ~/.ssh/key_filename
 User   git

あと、~/.ssh/configなどはパーミッションを600なりにしないとエラーになるので注意。

$ git push
Bad owner or permissions on /home/username/.ssh/config
fatal: The remote end hung up unexpectedly
$