2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

gitでエラーメモ書き Windows

Last updated at Posted at 2021-09-13

#いつもと違うPCのときに遭遇したエラー

git push リモートリポジトリ名 master
fatal: 'リモートリポジトリ名' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

###リモートリポジトリの指定

git remote add リモートリポジトリ名 リモートリポジトリのURL

###公開鍵を作成

ssh-keygen -t rsa -C "アカウントのメールアドレス"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/PCユーザー名/.ssh/id_rsa): /Users/PCユーザー名/.ssh/鍵の名前(なんでもOK)
Enter passphrase (empty for no passphrase):"パスを入力"
Enter same passphrase again:"パスを再入力"
Your identification has been saved in /Users/PCユーザー名/.ssh/鍵の名前.
Your public key has been saved in /Users/PCユーザー名/.ssh/鍵の名前.pub.
The key fingerprint is:
以下省略

###作成した公開鍵の中身をコピー(Windows)
clip < ~/.ssh/鍵の名前.pub

###github上で登録
使用したいレポジトリ>Settings>Deploykeys
Title:任意
Key:コピーした公開鍵の中身を張り付ける
Add keyを押す

###git bashでpush

git push リモートリポジトリ名 master

(うまくいかなかったら-fオプションで強制的にpush)

#gut push時に遭遇した(error: 403)

remote: Permission to ユーザ名/リポジトリ名.git denied to
fatal: unable to access 'https://github.com/ユーザ名/リポジトリ名.git/': The requested URL returned error: 403

###URLにユーザ名

git remote set-url origin https://<ユーザ名>@github.com/<ユーザ名>/<リポジトリ名>.git

#gut commit時に遭遇した

error: pathspec 'commit'' did not match any file(s) known to git

###ダブルクォーテーションで
git commit -m "first commit"

#git remote add時に(fatal: remote origin already exists.)

git remote add origin https://github.com/ユーザ名/リポジトリ名.git
error: remote origin already exists.

一度originを削除し

git remote rm origin
git remote add origin git@github.com:ユーザ名/リポジトリ名.git

#そのほか困ったら

git status
git log
git show
git remote
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?