Unresolvable reference when .git is a file (git worktree support)
See original GitHub issueGit will sometimes configure the .git file to be a file, instead of a directory. This file has contents similar to:
gitdir: /home/awwright/repo.git/worktrees/work
This happens, among other cases, when a working tree is created with git-worktree
. Here is a script showing the difference in behavior:
NAME=$(uuidgen).test
mkdir $NAME
pushd $NAME
git clone https://github.com/isomorphic-git/test.empty repo
git --git-dir=repo/.git worktree add work master
echo '{"dependencies":{"isomorphic-git":"0.55.0"}}' > package.json
yarn install
pushd work
echo
echo 'Git works:'
git log -1
echo
echo 'isomorphic-git bails:'
node -e 'require("isomorphic-git").log({depth:1, fs:require("fs"), dir:process.cwd(), ref:"HEAD"}).then(console.log, console.error);'
popd
pushd repo
echo
echo 'but it works in the default working tree:'
node -e 'require("isomorphic-git").log({depth:1, fs:require("fs"), dir:process.cwd(), ref:"HEAD"}).then(console.log, console.error);'
popd
popd
I would expect both calls to work, but only the second one does, with the first producing an error:
GitError [ResolveRefError]: Could not resolve reference "master".
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
git-worktree Documentation - Git
A git repository can support multiple working trees, allowing you to check out more than one branch at a time. With git worktree...
Read more >Why does git say "Pull is not possible because you have ...
It so happens, that your merge conflicts from (probably) the last commit were not not resolved, so your files are not merged all...
Read more >477475 – git 2.5 worktree support - Bugs - Eclipse
I've dropped new private build with worktree support based at ... in case of official JGit that does not support worktrees (.git files)....
Read more >Support additional worktrees · Issue #719 · gitpython ... - GitHub
I am curious how you got this working. The example where you used Repo.git.worktree("add", folder, branch) and then initialized with git.Repo() ...
Read more >Support git worktree feature : IDEA-143404 - YouTrack
This new working tree is called a "linked working tree" as opposed to the "main working tree" prepared by "git init" or "git...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, Antora supports git worktrees. See https://docs.antora.org/antora/latest/playbook/content-worktrees/ Please direct follow-up questions to the Antora project chat at https://chat.antora.org as we don’t want to bog down this issue talking about Antora.
Ahhhh… hmm. Two more implementation notes for myself or whoever implements this feature.
await
ed. Since this will involve filesystem read, we’ll have to move initializing it into the body of the function.git
follows this “link” even ifGIT_DIR
is explicitly set. So really we should leave it there and it should look more like this: