Will git prune a commit that is branchless but is tagged?

From what I understand, git will occasionally prune commits that are not reachable by any branches. However, does it still delete those commits, even if they have tags?

I was thinking of making some one off commits and tagging them, but only ever single commits, so no need for them to have branches attached.

  • How to create github Repository and upload files from windows using batch command
  • Why do rebased commit ids differ from cherry-picked ids?
  • I need to checkout single folder from a Bitbucket Git repo
  • 404 on Bluemix Toolchains
  • Merge two branches to create new branch
  • Git Post Hook to Kick Off Jenkins Job
  • get list of git branches for a repo hosted on github
  • How to have a separate branch for tagged commits only?
  • Can I have a workspace that is both a git workspace and a svn workspace?
  • remove file from all git history
  • How to create a sub branch?
  • Is it possible to merge renames in git if changes occur in a future commit than the rename?
  • 2 Solutions collect form web for “Will git prune a commit that is branchless but is tagged?”

    No, it will not delete any commits which are referenced by branches, tags, the index and so on or any parent of those commits. See “Notes” section of the help page for git gc:

    git gc tries very hard to be safe about the garbage it collects. In particular, it will keep not only objects referenced by your current set of branches and tags, but also objects referenced by the index, remote-tracking branches, refs saved by git filter-branch in refs/original/, or reflogs (which may reference commits in branches that were later amended or rewound).

    If you are expecting some objects to be collected and they aren’t, check all of those locations and decide whether it makes sense in your case to remove those references.

    No. Any commit that is reachable from any ref (branches, tags, even the stash), or transitively reachable (i.e. all their parents), are safe from being garbage collected for as long as those pointers to the commits exist.

    If you can reach your commit through a named reference, regardless of its type, you can be sure that it and its full history are available and will stay in the repository.

    Git Baby is a git and github fan, let's start git clone.