When I run git lg
on my local development branch, the latest commit is shown as below:
* 7d21213 - (1 hours ago) update business rules - developer1 (HEAD, origin/develop, origin/HEAD, develop)
However, if I stash local changes by running git stash
and then run git lg
, I get the following:
* at12334 - (13 seconds ago) WIP on develop: 7d21213 update business rules - developer1 (refs/stash)
|\
| * ef9a11b - (14 seconds ago) index on develop: 7d21213 update business rules - developer1
|/
* 7d21213 - (1 hours ago) update business rules - developer1 (HEAD, origin/develop, origin/HEAD, develop)
What does this mean? It seems that two new commits (labelled index
and WIP
) are created after stashing. Is that the case, and, if so, what is the logic behind such commits?
git lg
is an alias already defined in the test environment as
git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)' --all
git lg
? What git lg
?Be aware that lg
is not a native Git verb. True, many people use an alias called lg
that usually corresponds to
git log --all --oneline --graph --decorate
This definition seems to be the one you're using, here. However, aliases are local; what git lg
means in your config may be different to what it means in Bob and Alice's configs.
Therefore, you should always include the definition of a relevant alias in your question, so we (Stack Overflow users) can be on the same page as you, and know exactly what happens when you run
git <alias>
(git lg
, here).
This is explained in the Discussion section of the git-stash
man page:
A stash is represented as a commit whose tree records the state of the working directory, and its first parent is the commit at HEAD when the stash was created. The tree of the second parent records the state of the index when the stash is made, and it is made a child of the HEAD commit. The ancestry graph looks like this:
.----W / / -----H----I
where
H
is theHEAD
commit,I
is a commit that records the state of the index, andW
is a commit that records the state of the working tree.
In your case,
ef9a11b
corresponds to the state of your index (I
on the graph above),at12334
corresponds to the state of your working directory (W
on the graph above).Those two objects (W
and I
) don't normally get listed in the output of git log
, but they do if you use the --all
flag.