Reputation:
I am working on automating git operations using Unix shell scripting, and I need a bit of help on a specific merge operation.
Assume I want to merge two branches - branch A and B And, I am doing something like this in my script
git checkout A; git merge -X theirs--no-ff --no-commit B
There is a file (9.sql) which exists in branch B, however it's deleted in branch A.
When I execute the above command, it says Already up-to-date, but when I do the reverse merging, the file is deleted from branch B.
My question is, even if I use -X theirs, the file from branch B is not added to branch A, which is required.
What should I do?
Upvotes: 2
Views: 1945
Reputation: 67772
For that to happen, presumably the file existed in the common ancestor, was never changed on branch B, and was deleted on branch A.
In this case, you don't really want a recursive merge which uses theirs
as the option to resolve conflicts. That is,
git merge -X theirs
means use the default recursive strategy with option theirs. It's equivalent to
git merge -s recursive -X theirs
What you actually want is to use a different strategy, such as:
git merge -s theirs
which unfortunately doesn't exist.
If you want to pretend a merge happened but really make the tree identical to B, you can do that. If not, I'm not sure what kind if result you expect.
Upvotes: 1