MATLAB Answers

Problem in creating a new local Git repository

14 views (last 30 days)
Roberto Dima
Roberto Dima on 24 Oct 2020
Edited: Mario Malic on 26 Oct 2020
I've just discovered that Matlab 2020b implements a built-in git integration. I tried to create a new repository without success.
As far as I know, when you use the command git init in "A" folder, git will create an hidden .git folder in "A" where all snapshots are stored. So, I opened my project folder in Matlab, right clicked in current empty folder and then clicked on source control -> manage files. When the dialog box opens, I selected:
  • "A\.git" as Repository path
  • "A" as Sandbox
But I received this errore message: "Destination path "A" already exists and is not an empty directory".
I also tried others configurations:
  • "A" as Repository path
  • "A" as Sandbox
I'm able to finish the procedure if and only if I choose two not related folders, ie. "B" and "A". In this case, however, I'll find git files both in "B" and in "A\.git" folder which is automatically created.
How could obtain the typical git behaviour?


Show 2 older comments
Mario Malic
Mario Malic on 26 Oct 2020
In MATLAB, IIRC one project per folder, I am not sure whether it's possible to have another project folder within another project. See link here for some guidance There's a Source Control topic as well.
Roberto Dima
Roberto Dima on 26 Oct 2020
Surely I will deepen the topic "projects" but I did not mean that. I'm sorry because I don't speak English very well, but I'll try to be more clear: I have an "example" folder with several .m files. There is no .prj file. I would like to create a git repository associated with this folder in Matlab. Unfortunately I don't get the same result as the "git init" command in git Bash, that is to create a .git folder inside "example" where git keeps all its snapshots. What is the right procedure?
Mario Malic
Mario Malic on 26 Oct 2020
Example: Go to folder with all the files, New - Project - From Folder. After you selected it, from the toolbar click on Source Control, and then select Git and OK. Now you'll have the Source Control Toolbar to do whatever needed.
Hidden folders .git, resources, and .prj file, are not part of project by default.
What is the difference between !git init (MATLAB CMD window) and git init (shell/CMD)?
Edit: Just verified, you can have more projects within folders, but can't have two projects in the same folder.

Sign in to comment.

Answers (0)




Community Treasure Hunt

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

Start Hunting!

Translated by