LoginSignup
6
4

More than 5 years have passed since last update.

git rebase中に変更したファイルがないのにoverwritten by mergeというエラーになる

Last updated at Posted at 2015-12-16

発生した問題

リベース中に追加・変更したファイルがないのに、下記のようにマージエラーが出るようになってしまいました。

・
・
・
error: Your local changes to the following files would be overwritten by merge:
    app/models/hoge.rb
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.

この場合、リモートで変更のあったファイルをgit管理外にしてたりするのがよくある原因なのですが、今回はそういった設定は一切していませんでした。

またgit statusを実行したのですが、コンフリクトしているファイルなどは存在しない状況でした。

原因

どうやらMacのリビジョン管理に問題があって、リベース時にエラーが発生するようです。
ただ自分の環境でいうと、MacのOS上の時刻を変更していたのが原因っぽい?

解決方法

git config --global core.trustctime false

とコマンドを実行することで、インデックスと作業ツリー間のCTIMEの違いを無視してくれるので、マージエラーは出なくなります。

変更したファイルがないのにリベースエラーになったときは、この方法を試してみてください。

参考URL

Git rebase fails, 'Your local changes to the following files would be overwritten by merge'. No local changes? - Stack Overflow
A Simple Tweak for Making 'git rebase' Safe on OS X

6
4
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
6
4