0
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?

[Git] fatal: repository 'https://github.com/xx/' not foundの対処法

Last updated at Posted at 2024-09-20

まえがき(という名のわたくしごと)

はじめてQiitaとMarkDownを使ってみました。なのでエンジニアの方たちからすると凄く汚い記事になっていると思います。が、自分の成長のためにも忘備録がてら書いてみようと思います。
マサカリや指摘コメントしてくれるとすごくうれしいです。

詳細

該当コマンド↴

git push origin master

エラー↴

remote: Repository not found.
fatal: repository 'https://github.com/名前/リポジトリ/' not found

解決方法

ChatGPTに聞いてみると

  • エラーが発生する理由は適切なアクセス権を持っていないから
  • エラーを抑えるにはトークンを取得してURLにセットすればよい
    らしい

手順

アクセストークンの作成方法

  1. GitHubにログインする。
  2. 画面右上の自分のアイコンをクリックし、Settings を選択する。
  3. 左側のメニューで Developer settings を選択し、その中の Personal access tokensTokens (classic) をクリックする。
  4. 右上のGenerate new tokenGenerate new token (classic) をクリックする。
  5. repo スコープを選択する。
  6. Generate token をクリック
  7. トークンをコピーして保存する。(後で再表示できないためテキストファイル等にまとめておくと安心)

トークンは二度と表示できません。(多分)

5のExpirationはトークンの有効期限です。有効期限を過ぎたら使えなくなります。

GitBashで以下コマンドを実行します。

git remote set-url origin https://なまえ:とーくん@github.com/リポジトリ所有者/リポジトリ名.git

なまえにはユーザー名が、とーくんには先ほどのトークンが、リポジトリ所有者にはリポジトリ所有者のユーザー名が入ります。
例: ユーザー名=hoge_tarou; トークン=ghp_abcdefg; リポジトリ所有者のユーザー名=fuga_joshi;

git remote set-url origin https://hoge_tarou:ghp_abcdefg@github.com/fuga_joshi/リポジトリ名.git

あとはgit push origin master等のお好きなコマンドを打てばおkです

0
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
0
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?