I am trying to learn Git. This is my Git commit history
I want to delete the following loose commits:
I am reverting, rebasing and resetting the hell out of my Git repository. But no matter what I do, it seems the commit history will only grow. Any help?
The key to understanding this is that Git is all about commits. Each commits points to one or more parent commits (except the root commit which has no parent).
Branches are just "labels" to a single commit. This label is moved each time, you create a new commit on this branch. By following the parent points of commits, Git can reconstruct the history.
Branches (remember: labels) can be manually moved too, or they can be moved by other operations beside commit: merge, reset, rebase, etc.
When a commit becomes unreachable (sometimes "dangling") it means that no ref[^1] points to the commit any longer. A ref is usually a branch (=dynamic label) or a tag (=static label).
Git will not remove dangling commits immediately, but leaves them in your local repository. This allows you to go back to a previous state, in case that you have messed up. Old states of your branch are stored in the reflog – as you have discovered. The reflog maintains a list of all previously checked out commits.
Entries in the reflog expire after a given period of time. Consequently, the commits are really unreachable now. Git will automatically run garbage collection under certain circumstances (time, number of objects, etc.). When garbage collecting, truly unreachable commits will also be deleted for good from your repository.
TLDR: don't worry about them, they will be removed eventually.
[^1]: short for reference