Search code examples
gitconflictgit-submodulesgit-rebase

git submodule conflicts during rebase causes commit to disappear


I have this following scenario that keeps coming back:

  1. I commit a change in some files, along with an update to a submodule.
  2. Someone else commits and pushes an update to the same submodule.
  3. git pull --rebase, I get a conflict
  4. I fix the conflict by adding the latest version of the submodule.
  5. THE PROBLEM: Now, instead of the commit I made at step #1, I have a commit with ONLY the update to the submodule, without the other file changes.

I always fix this by either aborting rebase and using pull --no-rebase, or by cherry-picking the commit before rebase from the reflog.

There must be a better way.

Is there a good workaround for this common buggy scenario?


Solution

  • Might be a bug with an older version of git. Upgrading to a newer stable version is always a good idea when trying to fix weird stuff happening in software.