News for hackers. Stuff that matters.
Re:Ask HN: Can we do better than Git for version control? by bryanlarsen on Sunday December 10, 2023 @09:51AM (#38591865)
The git model has fundamental limitations because it saves snapshots rather than changes, and doesn't capture some metadata changes like renames. A tool like Darcs or one of its spiritual descendants will have fewer merge conflicts than git.

Totally agree on your main point though. The benefits of switching are far lower than the costs.

Re:Ask HN: Can we do better than Git for version control? by mikewarot on Sunday December 10, 2023 @12:14PM (#38593067)
>it saves snapshots rather than changes

Once you understand this, GIT makes a whole lot more sense. The trouble with failed merges is an artifact of trying to appear like it tracks deltas. Merge conflicts when you're the only programmer on a product (but have multiple computers) are maddening.

I blew away .git and everything in it, restarting a repository, more than once because I couldn't resolve a merge conflict, before I learned that simple fact.

I've got from .zip files of my source code on floppy disks, to SVN, then Mercurial, and finally GIT. GIT is amazing, though the UI is a pain, as most agree.

Re:Ask HN: Can we do better than Git for version control? by rendall on Sunday December 10, 2023 @12:23PM (#38593134)
> doesn't capture some metadata changes like renames

If you rename the file using git and that is the only change in your file, then it works:

  git mv oldfile newfile
Commit that change and the rename is in your history.
Re:Ask HN: Can we do better than Git for version control? by blibble on Sunday December 10, 2023 @12:32PM (#38593187)
the rename won't be in your history because the tree and commit objects don't support renames

the tooling infers a rename based on the lack of a content change

Re:Ask HN: Can we do better than Git for version control? by trevyn on Sunday December 10, 2023 @02:13PM (#38593994)
Is there a difference?
Re:Ask HN: Can we do better than Git for version control? by phyzome on Sunday December 10, 2023 @04:12PM (#38595101)
Absolutely. In a move-and-edit situation, git will sometimes infer a rename and sometimes not, based on your local version of git, your settings, and the details of the edit. If inference fails, you may have a harder time resolving merge conflicts, performing cherry-picks, etc.
Re:Ask HN: Can we do better than Git for version control? by trevyn on Friday December 15, 2023 @04:38AM (#38652538)
So just make sure the moves and edits are in separate commits?
Re:Ask HN: Can we do better than Git for version control? by phyzome on Sunday December 17, 2023 @08:38AM (#38672754)
Yes, that's the standard workaround.
Re:Ask HN: Can we do better than Git for version control? by dafelst on Sunday December 10, 2023 @05:54PM (#38595865)
Absolutely, the inference is based on a set of heuristics and is often just plain wrong.
Re:Ask HN: Can we do better than Git for version control? by rendall on Monday December 11, 2023 @09:43AM (#38601054)
I've had one or two really annoying merges that were complicated by these renames. TIL thanks to these responses that it's not actually a rename.
Re:Ask HN: Can we do better than Git for version control? by shard_ on Sunday December 10, 2023 @05:37PM (#38595758)
`git mv` is just shorthand for `git rm` and `git add`. All Git knows is that there was a file called `oldfile` and there's now a file called `newfile`, and whether or not they have similar contents or filenames. It's only when you run `git status` or `git diff` or whatever that it actually tries to guess if anything was renamed. So what you're seeing isn't the rename being recorded in history but just that guess being correct. It's easy for it to become incorrect if you make some nontrivial changes or have multiple similar files.
Re:Ask HN: Can we do better than Git for version control? by creatonez on Sunday December 10, 2023 @08:10PM (#38596619)
The parent comment's suggestion is to commit each of these moves individually, which should guarantee that the detection algorithm will get it right. Will definitely pollute your history, though.
Re:Ask HN: Can we do better than Git for version control? by Dylan16807 on Sunday December 10, 2023 @08:43PM (#38596768)
> If you rename the file using git

Does nothing. Git won't remember you did it.

> and that is the only change in your file

This always works, but it means you need to choose between flaky rename detection and weird extra rename-only commits that probably don't compile.

Re:Ask HN: Can we do better than Git for version control? by tehbeard on Sunday December 10, 2023 @10:55AM (#38592375)
> ..because it saves snapshots rather than changes..

I might be misremembering the technical details, but isn't that only the case in a git repo with zero pack files?

Will grant that the lack of metadata on renames can be issue when a file is heavily refactored alongside it's relocation.

Re:Ask HN: Can we do better than Git for version control? by bryanlarsen on Sunday December 10, 2023 @11:59AM (#38592938)
Re:Ask HN: Can we do better than Git for version control? by kevincox on Monday December 11, 2023 @12:26PM (#38602530)
Not only merge conflicts I find that this causes trouble if you need to manage multiple branches. Generally you see patterns like 1. Create patch 2. Merge to main branch 3. Backport a cherry pick.

But there is no machine-readable metadata that the commit is the same in both cases. In simple cases you can work around this by basing the patch off of the merge base but if there are conflicts that doesn't work well.

The result of this is that these two different but logically identically commits will cause future merge conflicts and make questions like "does this branch have this patch" much more difficult to answer.

This is something that I think https://pijul.org/ does quite well. Their base unit is a patch and that can be applied to multiple places. You can also have snapshots which are logically a collection of patches.

Re:Ask HN: Can we do better than Git for version control? by gitaarik on Wednesday December 13, 2023 @03:46AM (#38624417)
Don't the snapshots make it much faster than without?