LoginSignup
0

More than 5 years have passed since last update.

Updates were rejected because the tip of your current branch is behind となる場合

Last updated at Posted at 2017-07-29

ぼくは以下のようなエラーに遭遇することがなんどかあった。

$ git push origin piyo
To https://github.com/mochizukikotaro/sample.git
 ! [rejected]        piyo -> piyo (non-fast-forward)
error: failed to push some refs to 'https://github.com/mochizukikotaro/sample.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.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

ちなみにこのようになるのは、

master->piyo => PR だしてある
master->piyo2 => あとから PR だして、先にマージする

などの流れをやったときなどです。

このときに、`(e.g. git pull ...) などと書かれてるけど

$ git fetch origin
$ git pull rebase origin/piyo
#=> conflict が GitHub 上で発生するので、以下。

$ git merge master
#=> fix conflict
$ git push origin piyo

これで、事なきを得るのですが。あっているのか...

なんか間違ってる気がする..。

:moyai:

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