LoginSignup
1
0

More than 3 years have passed since last update.

git pushで ! [rejected] master -> master (non-fast-forward)が表示された際の対応方法の一例

Last updated at Posted at 2019-09-04

エラー内容

$ git push
To github.com:✖️✖️✖️✖️✖️✖️✖️✖️✖️.git
 ! [rejected]        master -> master (non-fast-forward)
以下省略

試してほしいこと

$ git remote show origin  (リモート詳細情報の確認)

・悪い例
* remote origin
  Fetch URL: git@github.com:✖️✖️✖️✖️✖️✖️✖️✖️✖️.git
  Push  URL: git@github.com:✖️✖️✖️✖️✖️✖️✖️✖️✖️.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (up to date)

・良い例
* remote origin
  Fetch URL: git@github.com:✖️✖️✖️✖️✖️✖️✖️✖️✖️.git
  Push  URL: git@github.com:✖️✖️✖️✖️✖️✖️✖️✖️✖️.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

もし上記の悪い例と同じ状況であるならgit pullも出来ないと思います。
下記の追跡コマンドを実行してみてください、正しく設定されるはずです。
(現在のローカルブランチにorigin/masterを追跡させるというコマンドになります)

$ git push -u origin master

今回の根本的なエラー内容はローカルのブランチに対して、それに対応する
リモートのブランチをマージする設定が行われてなかったということですね。

1
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
1
0