Ben
Ben

Reputation: 126

Git commits appear with git log but not with git log <filepath>

When I run git log --name-status I can see my files that were modified in my commits. However, when I run git log myfilename specifying one of the filenames that appeared in the previous command some commits are not listed.

Why could this be?

Upvotes: 1

Views: 73

Answers (1)

VonC
VonC

Reputation: 1329292

The commits appear when I use --follow or --full-history.

That means your file has been :

  • renamed (--follow)
  • involved with merged branches (--full-history, since the default mode prunes some side branches if the end result is the same (i.e. merging branches with the same content)

See the blog post "Git – Full History" from Scott Smith:

a series of changes can cancel each other out which means that history is “simplified” by default.
Those changes that cancel each other out will appear to have never existed without using the “–full-history” switch.

Ben confirms the second case in the comments:

what happened was first the changes that I made on my branch were merged back to the main line.
Afterwards the same changes were duplicated on another branch by another developer and then merged back in to the main line.

Upvotes: 1

Related Questions