git problem while simulink file is open

3 次查看(过去 30 天)
I'm using git for source control in Simulink.
The problem is Simulink locks all open files, and whenever I want to do any operation in git which changes the files, I should close all Simulink files which are open in that git repository. do the operation and then again open all of the changed files. This takes time and is very annoying.
Is there any workaround for this, most programs and editors that I use with git allow git to change the open files and refresh after change is detected. here is a simple example, there are two git branches, master and dev, if currently dev is active and I want to checkout to master branch I get this error:
$ git checkout master
error: unable to create file file1.slx: Permission denied
Switched to branch 'master'
It actually gets worst, although git can't change the file it checks out to master branch anyway and now we have the file from dev branch in master branch!

回答(1 个)

Swastik Sarkar
Swastik Sarkar 2024-8-2
Hi @Ali,
When working with version control systems like Git, one should ensure that files are not locked or in use by other applications, to close all open files in MATLAB, use the following command:
fclose("all")
Refer to the below MathWorks documentation link to read more about “fclose” function:
You can also set up a “pre-checkout hook” in Git to ensure that all necessary files are closed before performing Git checkout.
You can read more about Git hooks here:
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Source Control 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by