melkamo
melkamo

Reputation: 642

How to prevent changes being overwritten when merging branches?

I'm new to Git (coming from Subversion and Bazaar).

When I've been working on a branch and made a commit, and since then the master has had some commits take place, when I merge my branch into the master, I find some strange occurrences:

Can I tell Git to be stricter with these conflicts? I don't want it to overwrite files without warning, and if it's going to comment files for me to inspect, I'd prefer it provide absolute comments of total differences.

If not, I'm forced to determine the files that have been modified by both myself, and then manually merge them.

Upvotes: 2

Views: 721

Answers (1)

Karl Bielefeldt
Karl Bielefeldt

Reputation: 49128

When I try your first scenario, I get the following output:

Auto-merging conflicted
CONFLICT (add/add): Merge conflict in <filename>

Your second scenario will produce conflicts on lines that are different between the two versions, but not lines that only changed in one version or the other. This is expected behavior.

Git actually handles these sorts of conflicts better than most any other VCS. There's something else about your process that's causing issues. Maybe you have some rare config setting. Maybe you're misinterpreting the meaning of a flag you're using on one of the commands. Maybe some files haven't actually been committed in your or your colleague's working directory. Maybe you're in a different branch than you thought. Find an exact, reproducible sequence of commands that doesn't do as you expect, and we can try to help you from there.

Upvotes: 2

Related Questions