0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ローカルのコミットとリモートのコミットが食い違った場合は git pull --rebase が便利

0
Last updated at Posted at 2026-01-07

こんなことやってアワアワしてしまうことがよくあります。自分だけでしょうか。

  1. ローカルでコミットをする
  2. ローカルのコミットをpushする前にリモート上で最新のdevelopを取り込む
  3. ローカルでgit pullするとなんだか怖いエラーが出てびっくりする

解決策:git pull --rebaseを使う

git pull --rebaseを使うと以下のような挙動になります。

  • まずローカルコミットは抜きにしてローカルブランチを最新の状態にする
  • ローカルブランチが最新の状態になったら、その上にローカルコミットをくっつける

便利ですね💡

なお、親ブランチの修正箇所とローカルコミットの変更箇所が重なっているとコンフリクトが起きる可能性があるため、そこだけ注意する必要がありそうです。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?