skip to content
Alvin Lucillo

Worktrees share repo metadata

/ 1 min read

In yesterday’s journal, I’ve shown how to create a new worktree and how they’re related in the git history of the repo by showing the git log. We’ll try to merge feature branch with the main branch to demo this further. But first, here’s the recap of the worktree list and git log.

git worktree list
worktree-demo     ff49b47 [main]
worktree-feature  ff49b47 [feature-update]
git log --oneline --graph --all
* a65991e (feature-update) Update app text
* ff49b47 (HEAD -> main) Initial commit

After merge, we can see now that both branches point to the same commit that originated from the feature branch. This demonstrates that although worktree is a separate folder, they share branch metadata. They’re not just repos cloned in different folders.

git merge feature-update
Updating ff49b47..a65991e
Fast-forward
 app.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cat app.txt
Hello from feature branch

git log --oneline --graph --all
* a65991e (HEAD -> main, feature-update) Update app text
* ff49b47 Initial commit