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 push で failed to push some refs エラーが発生する

0
Posted at

この記事は過去のエラー解決メモを整理したものです。
現在の推奨手順とは異なる可能性があります。
公式ドキュメントを確認して最新情報と差分がないかを確認してください。

事象

VSCodeで作成したファイルを git init でGitHubに連携し、GitHubの案内に従って git push したところエラーが発生した。
(git branch -M mainまでエラーなし)

git remote add origin [URL]  # ローカルリポジトリと、リモートリポジトリとの連携
git branch -M main           # ローカルに新規ブランチの作成
git push -u origin main      # ローカルコミットされている内容をリモートにpush
error: failed to push some refs to 'https://github.com/ARFCAC/programs.git'

環境

  • Windows 11
  • Git
  • GitHub
  • VSCode 1.64.2
  • GitHubにSSHキー登録済み
  • Gitのユーザー名・メールアドレス設定済み

原因

  • 新規作成したローカルファイルよりリモートファイルの方が新しい状態になっていたこと

対策

解決策1

  1. git remote add origin [URL] を実行する(未設定の場合)。
  2. git fetch でリモートの最新状態をローカルに取得する。
  3. git merge で取得した内容をローカルに統合する。

解決策2

  • git clone を使う
  1. VSCodeの[ソース管理]から[クローン]を選択する
  2. URLとclone先のフォルダを選択する

参考情報

【初心者向け】GithubとローカルPCとの連携 - Qiita

git pushエラー:error: failed to push some refs to...はリモートの方が新しいのでプッシュできないという意味

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?