feature/XY
is the name of a feature branch and is currently checked out. feature/XY-refactor
is the name of another branch, that branched off of feature/XY
.
When I run git log --oneline
, I get the output below.
What does it mean that these two are right one after the other at the very top of the log output? I am using git bash on Windows.
user@host ~/Documents/repo (feature/XY)
$ git log --oneline
9feb11a (HEAD -> feature/XY, origin/feature/XY) Axis labels
d250b90 (feature/XY-refactor) Refactored
87d49c1 Fix typoe
6a8a7c7 Fix print statement
945ffca Fix code layout
3e747c9 Added spaces after comma
b143713 Changed fontsize
a669cd4 Commented out a print statement
// .. more commits
git log
will return all the commits reachable from a specific commit or set of commits (i.e. the history up to the specified commit(s)). When you don't specify a commit, it defaults toHEAD
.So you effectively ran
git log --oneline HEAD
which is equivalent togit log --oneline feature/XY
(the checked out branch).Thus your
git log
result is telling you that yourfeature/XY
branch has as its parent (or one of its parents if9feb11a
is a merge commit) the last commit of thefeature/XY-refactor
branch. In other words, thefeature/XY-refactor
branch has been merged intofeature/XY
one way or another.git log
shows a list of commits in chronological order but not their exact relationships. To see that use the--graph
switch, which works especially well with--oneline
:For example, if
feature/XY-refactor
branched off at commit3e747c9
, and was then merged withfeature/XY
before any separate work was done onfeature/XY
you would see the following:Or if
feature/XY
was rebased ontofeature/XY-refactor
, you would see the following:When you use
--graph
, it may reorder the commits to make a cleaner graph.There is one flaw with
git log --graph
: It doesn't make it obvious when you have two or more separate commit histories that don't share a common root commit. But that is unlikely to be your case based on what you said.Anyway, you can always see the history for any particular ref or "commitish" by giving it as an arg to
git log
. Try these commands:If you want to see how two or more branches relate:
If you want to see ALL branches:
As a bonus, here's an even more detailed
git log
command, showing dates, times and author: