@takaiko001

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

GitでGithubと連絡してフォルダを送れない

解決したいこと:
すでに作られているGitのフォルダ、ファイル群をGithubにアップロードしてgit管理したい

発生している問題・エラー:
gitでリモートにpushしたいデータがあるのですが、git push origin mainとすると下記のエラーが出てきてしまい、困っています。
(一人での環境ですが、今後の勉強のためにリモート操作ができるようになっていたいと思っています。)
error: failed to push some refs to 'github.com:名前/リポジトリ名.git'

出ているエラーメッセージを入力:
error: failed to push some refs to 'github.com:名前/リポジトリ名.git'

または、問題・エラーが起きている画像をここにドラッグアンドドロップ
エラー.png

該当するソースコード

ソースコードを入力
```git push origin main

自分で試したこと

念のため、今の状態を記しておきます。

git push - origin main
error: src refspec origin does not match any
error: src refspec main does not match any
error: failed to push some refs to '-'

git push --force-with-lease
fatal: The current branch 'main' has no upstream branch.
To push the current branch and set the remote as upstream, use

git push -f
fatal: The current branch 'main' has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream origin 'main'

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

git pull origin main
The authenticity of host 'github.com (64:ff9b::141b:b171)' can't be established.
ED25519 key fingerprint is: SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: y
Please type 'yes', 'no' or the fingerprint:
Host key verification failed.
fatal: Could not read from remote repository.

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

git pull origin 名前
The authenticity of host 'github.com (64:ff9b::141b:b171)' can't be established.
ED25519 key fingerprint is: SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? testRepository
Please type 'yes', 'no' or the fingerprint:
Host key verification failed.
fatal: Could not read from remote repository.

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

git remote add origin https://github.com/名前/リポジトリ名.git

今、試せないのが公開鍵と秘密鍵でSSH接続をするというものですが、これもやり方がわかりません。

かなり初心者なので、足りない情報などございましたらお答します。
ご教授よろしくお願いいたします。

0 likes

2Answer

エラーは 「まだ一度もコミットしていない状態で push しようとしている」ことが主な原因だと思う。

まず現在の状態を確認したいです。
GitHubに上げたいフォルダの直下で、以下を実行してください。

git status

もし、

fatal: not a git repository

と出る場合は、次のコマンドで初期化します。

git init

ブランチ名を確認(main か master か)

git branch
  • * main → OK
  • * master → master が現在のブランチです、masterになってませんか?

最初のコミットを作成

この操作を 一度もしていないと push できないです。

git add .
git commit -m "first commit"

これでようやく「pushできるデータ」が作られます。

もし、この辺りいじってから、まだうまくいかないときは、

  • git status
  • git branch
  • git remote -v
  • git push
    実行時のエラーメッセージ全文もらえたら、原因を特定できそう。
3Like

お返事遅くなり申し訳ございません。

おっしゃったことをためした結果を画像でお送りいたします。説明用.png

前に「ポート番号」が誤っていますという表示も出てきて、サーバー関連のことは全くわからないので困っています。

宜しくお願いいたします。

0Like

Comments

  1. 今の状態を見ると、

    1push コマンドを正しい形で実行する

    Git がメッセージで提案してくれている通り、本来は:

    git push --set-upstream origin main
    

    とする必要があります。

    今は local という名前を書いてしまっているので、そこを origin に直して、上のコマンドをもう一度実行してみてください。

    2それでも「Repository not found」が出る場合

    もし、上のコマンドでまだ

    remote: Repository not found.
    fatal: repository 'https://github.com/***/testRepository.git/' not found
    

    というエラーが出るようであれば、GitHub 側のリポジトリ名/URL を確認してみてください。まだ、存在しなかったら作ってあげてください。

  2. @takaiko001

    Questioner

    丁寧に有難うございます!!(!!)/
    今、おっしゃったことを試しているのですが、エラーの嵐で悲しくなってきました。
    ちょっと長くなる、また一つ一つに分けて質問した方が質問タグ的にいいと思ったので、(サーバーの知識が必要なものもあるため)こっちはいったんクローズします。のちほどベストアンサーにさせて頂きます。

  3. @takaiko001

    Questioner

    すみません、ベストアンサー機能もないようなのでここでお礼申し上げます。
    まことにありがとうございました。

Your answer might help someone💌

AltStyle によって変換されたページ (->オリジナル) /