0
0

More than 1 year has passed since last update.

Gitコマンド(push)操作エラーについて

Posted at

pushした際のエラー解消

今回のエラー内容・・・リモートリポジトリに直接画像ファイルをアップした事によるもの。

error: failed to push some refs to 'https://github●●'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

という表示が、GitHubにpushした際に出た。

解決策

まずはhint通り、pullしましょう

  git pull origin main

でエラー出なかったら、pushする。

なお、mainの部分は、各々のブランチを指定する。
pullして以下の

error: The following untracked working tree files would be overwritten by merge:
	images1/private.png
	images1/public.png
Please move or remove them before you merge.

というエラーが出れば、未追跡ファイルが作業ツリーに存在しているので、マージが中止されたことを示しています。

未追跡ファイルを削除するか次のstashコマンドを使用して一時的に保存します。

  git stash push --include-untracked

あとは、git pushでリモートリポジトリにpush出来るはず!

ちなみにこれらのエラーが出た原因は、GitHubに直接imagesファイルをドラッグ&ドロップでアップロードしていたことが原因であった。

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