With git log --graph --all --oneline
I have:
* G (HEAD -> main, origin/main)
...
* F
* E
* D
* C
* B
| * Z
|/
* A
But if the --all
flag is omitted, then the graph is:
* G (HEAD -> main, origin/main)
...
* F
* E
My questions are:
A
, B
, C
, D
are reachable from main
. Why doesn't git log
show them?Z
isn't reachable from any ref. Why does git log --all
show it?A
, B
, C
, D
or Z
seems to be reachable from main
. Why doesn't git log
show them?It's because the --oneline
flag accidentally obfuscates the graph, making them look like being reachable from main
, while in fact they aren't. Omitting that flag reveals that there are actually two root commits, E
and A
, and the disconnection between them.
A
, B
, C
, D
or Z
. Why does git log --all
show them?It's because there are more refs than branches, tags and HEAD, and I suspect the command only show them by default. To reveal all refs, use git log --all --source
. Or you can use git for-each-ref
to examine only the commits being attached to a ref:
git for-each-ref --format="%(objectname:short) %(refname)"
G refs/heads/main
D refs/original/refs/heads/main
Z refs/original/refs/tags/Cấutrúc1
C refs/original/refs/tags/Cấutrúc1.1
G refs/remotes/origin/main
To solve the problem, open the file .git/packed-refs
and delete all lines containing the refs/original/refs/
string.
Next question: What does refs/original
do?
Thanks TTT, matt, LeGEC for helping me investigate the problem.