Use case: I want to mirror a bunch of repositories of a project. I suppose this would be pretty easy with a script.

But to the git part: I fear that the developers might force push things and thus revert commits and de facto delete code.

Is there a way to git clone and auto-checking out to a different branch or something else, to avoid force pulling and reverting commits?

  • dgdft@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    3 days ago

    Great answer on the whole, but worth noting that both Git’s standard CLI client and most hosted git services do run periodic GC to prune dangling commits.

    I second the suggestion to take periodic snapshots of your mirror. Because the majority of file contents will not be changing over time, you can make these snapshots very disk-space efficient by taking binary diffs of the tar’d repo using rdiff or the like.

    • just_another_person@lemmy.world
      link
      fedilink
      arrow-up
      1
      arrow-down
      1
      ·
      3 days ago

      Pruning clears cached blobs and unlinked objects. It 100% will not clear history unless you’re forcing a specific depth to be achieved, which, again, is not something that people who want a functional repo would do.

      • dgdft@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        arrow-down
        1
        ·
        3 days ago

        Dangling commits are unlinked objects, and happen pretty frequently if you’re using hard resets instead of explicit git reverts.

        Not arguing that it’s good practice but it’s very common.