3

In a repo I'm working on, dozens of feature branches have been created, worked on, merged to master, and then deleted when done. However, I can still see every single commit in any of those branches with git log --graph. With the SHAs in the graph, I can also checkout any commit in those deleted branches.

I think it's a very good thing, but my question is, are they going to be garbage-collected sometime in the future, or are they permanent?

DrZYin
  • 145
  • 10
  • 1
    Those feature branches are just as much a part of the history as the other parent in the merge commit. Most likely, you would certainly want this history present. – Tim Biegeleisen Jan 15 '18 at 05:30

1 Answers1

3

Permanent: as long as those commits are accessible through a branch or a tag, they will remain visible.
Accessible means: you can go back from a tagged commit or a branch HEAD to those older commits, through the graph of commits: see "Understand Git history ".

If they are not accessible, then they are visible through git reflog, and garbage collected eventually (gc.reflogExpire is by default 90 days), or before with git gc.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • So anything visible through `git log --graph --all` is permanent (unless you rewrite history); everything else will eventually be cleaned up. – Daniel H Jan 15 '18 at 05:36
  • @DanielH That is the general idea, yes. – VonC Jan 15 '18 at 05:37
  • Do you know of any exceptions to that? I think it's exactly correct, but there might be an edge case I'm not thinking of. – Daniel H Jan 15 '18 at 05:52
  • @DanielH Not that I know of. And this is why, if you delete something, clean your repo (gc) and push a deletion... you still need to contact the remote server support to ask for a similar cleanup: https://stackoverflow.com/a/47771133/6309 – VonC Jan 15 '18 at 05:55