Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to my these several times git pull --rebase with the error "Your local changes to the following files would be overwritten by merge"

Tags:

git

git-rebase

I used git pull --rebase to pull the newest code, while I had one commit that is head of remote origin. But I got error when I tried it first two times, but at the the third time, it worked fine.

The First Time:

remote: Counting objects: 165, done.
remote: Compressing objects: 100% (56/56), done.
remote: Total 111 (delta 77), reused 84 (delta 50)
Receiving objects: 100% (111/111), 18.37 KiB, done.
Resolving deltas: 100% (77/77), completed with 45 local objects.
From github.com:gumichina/crosskaiser-native
   e39c920..0491ecf  master     -> origin/master
First, rewinding head to replay your work on top of it...
Applying: complete friend list
Using index info to reconstruct a base tree...
M   application/Resources/CrossKaiser.ccbresourcelog
<stdin>:62: trailing whitespace.

<stdin>:100: trailing whitespace.

<stdin>:190: new blank line at EOF.
+
warning: 3 lines add whitespace errors.
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
    application/Classes/CoverLayer/CoverLayer.cpp
    application/Classes/Friend/FriendList.cpp
    application/Classes/Friend/FriendList.h
    application/Classes/Friend/FriendListItem.h
    application/Classes/Friend/FriendListScene.cpp
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.
Patch failed at 0001 complete friend list
The copy of the patch that failed is found in:
   /Users/tangyue/project/crosskaiser-native/.git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

Then I type git status, it shown below:

# Not currently on any branch.
# You are currently rebasing.
#   (all conflicts fixed: run "git rebase --continue")
#
nothing to commit, working directory clean

It was strange that it changed to a detach branch, and no any changed files.

So I aborted it with git rebase --abort.

The Second Time:

First, rewinding head to replay your work on top of it...
Applying: complete friend list
Using index info to reconstruct a base tree...
M   application/Resources/CrossKaiser.ccbresourcelog
<stdin>:62: trailing whitespace.

<stdin>:100: trailing whitespace.

<stdin>:190: new blank line at EOF.
+
warning: 3 lines add whitespace errors.
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
    application/Classes/Friend/FriendListItem.cpp
    application/Classes/Friend/FriendListScene.cpp
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.
Patch failed at 0001 complete friend list
The copy of the patch that failed is found in:
   /Users/tangyue/project/crosskaiser-native/.git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

Then, I looked at git status:

# Not currently on any branch.
# You are currently rebasing.
#   (all conflicts fixed: run "git rebase --continue")
#
nothing to commit, working directory clean

And it was very similar to the first time.

Again I aborted it with git rebase --abort.

The Third Time:

First, rewinding head to replay your work on top of it...
Applying: complete friend list
Using index info to reconstruct a base tree...
M   application/Resources/CrossKaiser.ccbresourcelog
<stdin>:62: trailing whitespace.

<stdin>:100: trailing whitespace.

<stdin>:190: new blank line at EOF.
+
warning: 3 lines add whitespace errors.
Falling back to patching base and 3-way merge...

And this time, it worked fine with no error.

Now the log looked like below:

* 25f45f8 (HEAD, master) complete friend list
* 0491ecf (origin/master, origin/HEAD) add need_level to stage
* 8eb488e modify deck manager
* 1deef55 add status bar for sell scene
* 46f57b5 manage dialog&menu button priority
* 491d7e6 modify card template
* 9d09b34 add stamina dialog
* e39c920 complete TextInput
* a60d1b3 fix the name of template

Can anybody tell me, what happened during the all operation? And why I could git pull --rebase correctly after two times incorrectly?

like image 695
pktangyue Avatar asked Feb 28 '13 13:02

pktangyue


1 Answers

It could be related to this. I had the same problem as you do for a long time, this helped. I couldn't find any consensus on the reason for this, though (Here is some more discussions). It seems that something is changing file meta data, essentially resetting the ctime of your files, so that git will not recognize them as changed when relying on ctime information.

Links to git documentation of trustctime: git-config, git-update-index

like image 164
Nils_M Avatar answered Oct 14 '22 00:10

Nils_M