Not really. That isn't something git tracks. In fact, it doesn't even track the fact that newbranch
was specifically branched "from master
". (As an aside, I suggest not using "fork" to refer to the relationship between branches, since "fork" has a specific meaning with git repos and OSS projects in general.)
As RomainValeri suggests, you might be able, under specific circumstances, to look at filesystem timestamps for the metadata associated with the branch; but those aren't guaranteed to mean anything. Sometimes the file they mention either won't exist, or will have been created at a time that bears no relationship to branch creation. And even if it does exist and does reflect the right timestamp, it won't mean much; because "creating a branch" only means that a new ref was created. It doesn't mean it is (or ever was) checked out, or say anything about which ref(s) would contain new commits.
The easiest way to visualize how things are now is to get a commit graph that shows the positions of branches and other refs. You could use something like git log --graph --all --full-history
. (The --full-history
option is probably unnecessary, but since the point is that we're not exactly sure what's going on, this will give the most true picture.) Or you might find a GUI makes it easier to read; I often use gitk --all --full-history
when I need to look at the "big picture".
Keep in mind that the commits from before the branch was created definitely will be shown by default. That is, if you have
A -- B -- C <--(master)
\
D <--(newbranch)
then a log of D
by default includes A
, B
, and D
, as this is the full history of the code as it exists at newbranch
. If you're seeing C
, that suggests that you really aren't on newbranch
at all (and the above graph isn't what you really have in that case).
The rest of this may be a tangent, but just in case...
The reason A
and B
are included by default is because, again, git doesn't know/care which branch was created from which other branch, or anything like that. In the above picture, newbranch
could have been the original branch and master
could've been branched from it at B
; to git, this is the same as newbranch
being branched from master
at B
. Or D
could've been created in detached HEAD state, and newbranch
could've been created after the fact to preserve D
. Or a lot of other things could happen.
If you want to see just commits that were added on newbranch
, you could say something like git log master..newbranch
(telling log to exclude any commits that are part of master
's history).