1. ホーム
  2. github

git push reports errorsUpdates were rejected because because the remote contains work that you do

2022-02-19 04:33:43
<パス

今日、githubで、リポジトリの切り替えで以下のような問題が発生しました。
を実行した後 git push -u origin master 以下のような問題が発生しました。

 [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/chauncheng/machine-learning.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have local. This is usually caused by another repository pushing
You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again. before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


のイシュー処理。

の必要性をブログで紹介

git pull origin master


次に `execute' を実行します。

git push -u origin master


以下のように、やはりエラーが発生します。

error: failed to push some refs to 'https://github.com/chaunchengZeng/machine-learning.git'
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. before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


今回は、新しいブランチを作成する必要があります。

git branch Branch name


次にプッシュ

git push -u origin branch name


これは問題を解決する