leif.gruenwoldt
leif.gruenwoldt

Reputation: 13977

git merge does not contain my changes

I have two git branches B1 and B2. B2 has the newest copy of my file F. When I merge B2 into B1 ( git checkout B1 && git merge B2 ) the log for F ( git log F) does not contain any of the commits that had been done on B2. I only see commits C1-C3 that existed previously on B1. But when I do (git log --follow F) I see the commits on B1 from B2, C4-C6. However when I open the file F to inspect it it does not contain those changes from commits C4-C6. What's going on?

Upvotes: 0

Views: 1353

Answers (2)

Adam Dymitruk
Adam Dymitruk

Reputation: 129744

You shouldn't need to use "follow" unless you renamed the file. Try git log B1 -- F to just filter on whether a commit affected that file.

Also use git blame F to see what commits the current lines in the file came from.

As you say the history is quite complicated. If there were conflicts in merges, you could have accepted the "theirs" side of a conflict and that would erase the visibility of changes introduced in the current branches history.

Upvotes: 1

Michel
Michel

Reputation: 544

I got this same problem after creating a branch and merging, the problem is that git does a fast-forward when your master is reachable from the branch.

To log this you have the argument

git merge --no-ff B2

Good luck.

Upvotes: 0

Related Questions