The rest I agree with, that objects and branches are shared between worktrees, as well as the repository configuration (e.g. remotes) is why I use worktrees, having to move things around and losing the content when I’d delete the wrong clone is why I stopped using them.
edit: spellchecker corrected reflinks, this is what I meant.
``` cd $(mktemp -d) git init test ( cd test; touch README.md; git add README.md; git commit -m "Test"; ) git clone test/.git test_clone find test_clone/.git/objects test/.git/objects -type f -printf "%i\t%p\n" | sort ```
You'll see the same inodes used in both clones.
CoW and reflinks let you share everything, including the non-immutable paths, and even stuff like node_modules.
// Didn't double-check, but I've held this belief for over decade now, would be surprised to be proven wrong
echo old > a
ln a b
echo new > a
cat a b # prints "new" and "new"
Some programs like GNU sed [1] do create new inodes, but that is a property of the application, not the filesystem: echo old > a
ln a b
sed -i 'c new' a
cat a b # prints "new" and "old"
With reflinks in a CoW filesystem the inodes are different from the start, but share the same underlying blocks: echo old > a
cp --reflink=always a b
ls -i a b # prints different inodes
echo new > a
cat a b # prints "new" and "old"
[1] https://www.gnu.org/software/sed/manual/html_node/Command_00...Thanks for examples and especially the doc link. I don't normally use hard links, and for some reason was sure that's how they behave.
Maybe my belief indeed stemmed from observing software which overwrites opened file with a new copy.
CoW is similar except the new inode is created by the file system itself and is independent of the editor.
For my purposes, the alternative with just switching branches or if parallelism is needed, full repos and remotes (including local path remotes) is just much more flexible. Clone local, branch it, optionally do anything later: push a branch back to the local repo, push it to a remote, delete local repo done.
The actual code and clean merges is much more significant than worktrees vs full clones