필터 지우기
필터 지우기

Can't add a file to a project from within a git worktree

조회 수: 11 (최근 30일)
Nickolai Belakovski
Nickolai Belakovski 2022년 6월 3일
답변: Ayush Yadav 2022년 6월 6일
This question concerns MATLAB Projects and git worktrees. git worktree lets you have another copy of a repo on the same machine, and to link the two. So instead of git clone into two separate directories, you add a 'worktree' to a separate directory. This is great because it saves space (the two worktrees share the .git folder of the original worktree), and the two repos are in sync (so when you do git fetch in one, the other is in sync, because they share the same .git folder).
Worktree doesn't seem to play nice with MATLAB projects though. If I'm in a worktree other than the original one, I can't use addPath(currentProject, 'myfolder'); or addFile(currentProject, 'myfile.m');
It gives me an error:
Error using matlab.project.Project/addFile
Unable to add files to source control.
Exception caught during execution of add command
The system cannot find the path specified
It's not specific as to which path it can't find, but from my testing I think it has to do with being in a worktree. I created an empty repo with just a project file, tried to add a file to it from the main repo and has no issues, then tried to add the file from a worktree and got this error.
MATLAB is still creating the necessary file, it just can't stage them in the worktree. Would be great if this could be fixed.

채택된 답변

Ayush Yadav
Ayush Yadav 2022년 6월 6일
Currently our git integration is based on JGit, which does not yet support worktrees.
Unfortunately there are no workarounds, other than using the git command line interface through MATLAB.. For example:
!git commit -m "message"
We have marked this as a potential enhancement and it might be considered in a future release.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Source Control Integration에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by