Reputation: 260
I have a problem understanding what goes wrong in the following scenario:
I have a feature branch X that is behind on development
, so I do a rebase of this feature branch by calling git rebase development
when the HEAD
is on this feature branch X. Git now replays all commits of my feature branch on development
, and it stops on a commit that has conflicts. I fixed the conflict by removing some files that shouldn't be there in the first place and added the folder to my .gitignore
then I continue by staging the changes and git rebase --continue
.
Now the rebase stops again on a commit that has changes to some of the files that I removed earlier. However, instead of noting that this specific file does not exist anymore, git
tries to apply the changes to a different file in the folder!
Why is this default behavior? (I run Git 2.0)
The diff of the conflicting file is like this:
++<<<<<<< HEAD:<path>/XML/fileA.xslt
+ [...]
+
++=======
+ [....]
+
++>>>>>>> <commit message>:<path>/XML/fileB.html
Upvotes: 4
Views: 562
Reputation: 14089
Why is this default behavior?
Each commit stores a tree of the files, when you rebase ( as I understand ) it simply merges each commit commit in starting from the base commit.
What happens when you resolve the conflict by say removing the file fileA.xslt
in the directory /XML/
which is itself is stored as a tree is something like this :
git ls-tree HEAD XML/
... blob ... fileA.xslt
... blob ... fileB.html
After removal the XML directory tree looks something like this :
git ls-tree HEAD XML/
... blob ... fileB.html
Now if you try to merge it again with a tree with the removed file present ( the commit where it is modified ) :
git ls-tree HEAD XML/
... blob ... fileA.xslt
... blob ... fileB.html
So my guess is to match it will probably try to convert the fileB.html
into fileA.xst
as they are both the first file in the different versions of the XML
tree or have been determined to be very similar.
BTW : You can do an interactive rebase and edit, skip, or reorder the commits if it is necessary.
Upvotes: 1
Reputation: 969
Because git doesn't record changes made, just snapshots, your changes were erroneously detected as renaming .xml to .html and replacing its' content with content of .html file. I think there might be some switch that provides hints for git on that matter, but I'm not sure.
Upvotes: 0