Help us understand the problem. What is going on with this article?

git pushがreject(拒否)されたときの対処法

リモートにプッシュした時、次のようなエラーが返ってきた。

To github.com:○○○○○○/○○○○○○○
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:○○○○○○/○○○○○○'
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.

状況確認

non-fast-forward は、下のような状況で言うとmasterブランチのリモートとローカルの最新情報が異なっていることを示す。そのため、通常のプッシュが行えず、rejectが表示される。

master    a --- b --- c --- d --- e
(リモート)
          
master    a --- b --- c --- d --- f
(ローカル)     

対処法1

$ git pull origin master  リモートの情報をローカルに持ってくる(自動的にマージも行われる)
$ git push origin master  最新情報が一致するため通常のプッシュが行える

対処法2

$ git push -f origin master   強制(force)的にプッシュする
President_Taka
36歳未経験から、AWSをメインに扱うCIer企業へ転職。自身のスキルアップのため、時々記事を書きます。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした