gitでpush時のエラーが出る時

pusu時エラー

gitpushエラー

push時のエラーが出る時

  • プッシュ時エラー
Pushing to https://github.com/mnes/lookrec-ehr-ordering
remote: Repository not found.
fatal: repository 'https://github.com/mnes/lookrec-ehr-ordering/' not found

httpsで登録されていないか確認

  • git config -listで確認
$ git config --list
  • httpsでの設定になっている。
remote.origin.url=https://github.com/USERNAME/REPO.git

sshの設定にアップデート

  • 変更
$ git remote set-url origin git@github.com:USERNAME/REPO.git

SSH接続エラー

PUSHでSSH接続時エラー

  • 以下が出る
Pushing to git@github.com:nmatsu2013/REPO.git
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

公開鍵・秘密鍵を作成する

  • 鍵を入れるフォルダに移動しましょう。
$cd ~/.ssh
  • はじめて鍵を生成するときは何も入っていないはずです。
  • 次のコマンドで鍵を生成します。
$ssh-keygen -t rsa
  • オプションは付けてある記事も見ますが、このコマンドで十分です。
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/(username)/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
  • 何か聞かれたら3回エンターを押せば、
  • id_rsaとid_rsa.pubの2つの鍵が生成されます。

公開鍵をGitHubにアップする

  • GITHub開く
  • 公開鍵の設定が出来ます。(GitHubに登録していることが前提条件です)
  • 画面右上の「Add SSH key」のボタンを押します。
  • 「title」に公開鍵名、「key」に公開鍵の中身を入れます。

  • なお、鍵の中身のクリップボードへのコピーは

$ pbcopy < ~/.ssh/id_rsa.pub (Mac)
$ vi ~/.ssh/config
  • 何も表示されていない場合は、下記内容をコピペする。
  • configファイルが既に存在する場合は下記内容を追記する。
#-------------------
Host github
  HostName github.com
  IdentityFile ~/.ssh/id_rsa
  User git
#-------------------

接続を確かめる

  • Hi (account名)! You've successfully authenticated, but GitHub does not provide shell access.
$ ssh -T git@github.com