I happen to have a file (say abc) in two branches: master and sample.
The commit date for abc on sample is older than abc on current master; in other words abc is latest on master.
Now, I ran:
git checkout sample
git merge master
It auto-merged several files (including abc).
Problem: Line#42 in abc seems to persist from branch sample instead getting replaced from master.
Why is this happening ? I was quite expecting otherwise. Please help.
The fact that abc is newer on master than on sample doesn't means it gets wholly replaced by the master version during merge. If sample's version of abc has some changes that are not present on master, even if they are older than the last change in master, git will try to preserve them during merge.