0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Git】既にあるリモートブランチに、再度pushするときのエラー

Posted at

前提

ローカルのfeature/Aでの開発を、一度リモートのfeature/Aにpush済。

状況

再度ローカルのfeature/Aで修正をした。

その間にリモートのdevelopに更新があったので、ローカルのdevelopにpullし、ローカルのfeature/Aをリベースした。

ここで再度ローカルのfeature/Aからリモートのfeature/Aにpushしたところ、エラーになる。

エラー内容

$ git push origin feature/A

// 結果
info: detecting host provider for 'https://fandmnet2.backlog.jp/'...
info: detecting host provider for 'https://fandmnet2.backlog.jp/'...
To https://fandmnet2.backlog.jp/git/HOJOSAPO/src.git
! [rejected]        feature/nagao/update_service_classes -> feature/nagao/update_service_classes (non-fast-forward)
error: failed to push some refs to 'https://fandmnet2.backlog.jp/git/HOJOSAPO/src.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.

解決法

$ git push -f origin feature/A

リベースの運用ではよく起こるエラー。

一つのプルリクエストにおいて、コミット履歴は自分のものだけを残したいので、-fオプションを付けて強制的にpushする。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?