• Pipoca@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    1 year ago

    One problem, I think, is that git names are kinda bad. A git branch is just a pointer to a commit, it really doesn’t correspond to what we’d naturally think of as a branch in the context of a physical tree or even in a graph.

    That’s a bit problematic for explaining git to programming newbies, because grokking pointers is famously one of the stumbling blocks people have, along with recursion. Front-end web developers who never learned C might not really grok pointers due to never really having to deal with them much.

    Some other version control systems like mercurial have both a branch in a more intuitive sense (commits have a branch as a bit of metadata), as well as pointers to commits (mercurial, for example, calls them bookmarks).

    As an aside, there’s a few version control systems like darcs where instead of the first-class concept being snapshots, it’s diffs. There’s no separate cherrypick command in darcs, it’s just one way you can use the regular commands.

    • sushibowl@feddit.nl
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      A git branch is just a pointer to a commit, it really doesn’t correspond to what we’d naturally think of as a branch in the context of a physical tree or even in a graph.

      But as the article points out, a commit includes all of its ancestors. Therefore pointing to a commit effectively is equivalent to a branch in the context of a tree.

      Some other version control systems like mercurial have both a branch in a more intuitive sense (commits have a branch as a bit of metadata), as well as pointers to commits (mercurial, for example, calls them bookmarks).

      I mean, git has bookmarks too, they’re called tags.

      • Pipoca@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        What happens after you merge a feature branch into main and delete it? What happens to the branch?

        Afterwords, what git commands can you run to see what commits were made as part of the feature branch and which were previously on main?

        Mercurial bookmarks correspond to git branches, while mercurial tags correspond to git tags.