Do I need to move my files and update my path to use git in Matlab?

6 Ansichten (letzte 30 Tage)
I've been using Matlab for many years without source control. I have a variety of directories spread across my computer with different types of m-files grouped in a somewhat logical way. I decided recently that I would like to start using the built-in git source control to manage my software better. Based on the documentation, it seems as if I'd have to reorganize my various files and directories so that they all reside in the sandbox location. Of course, this would also require updating the path definition to this new location as well.
Is this a necessary first step in doing source control? Or can I add source control to each of my already-existing directories separately?
  2 Kommentare
Stephen23
Stephen23 am 29 Feb. 2024
"Based on the documentation, it seems as if I'd have to reorganize my various files and directories so that they all reside in the sandbox location"
AFAIK that is not required. But you do need to appreciate that (for better of for worse) versioning tools generally consider everything under one directory to be one project. There is nothing stopping you from having multiple projects stored in a versioning system (that is usually how people use them) saved wherever you want, but they should not overlap (i.e. be sub-folders of each other).
Doug
Doug am 29 Feb. 2024
I was following Matlab help to create a local git repository. Step 7. says the sandbox folder must be empty. Based on that, it sounded like I would have to move my current working directories into the newly-created sandbox folder (then re-path my Matlab). I was hoping to avoid that.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Mike Croucher
Mike Croucher am 29 Feb. 2024
Hi Doug
The way to think about it is that source control begins in a root directory and everything else related to that project is inside that root directory. If you are looking at a set of files scattered around your filesystem, ask yourself "What logically consistent set of projects should these be turned into?" You would then have one repository per project.
In your case, I would ask myself "Imagine my computer exploded tomorrow, How quickly could I reproduce my code environment and what are the sensible sub-projects I could do to organise this.".
Alternatively, imagine a student starts working with you. Which of your files would they need to download and install? All of them? Probably not! The 3 projects that, together, represent the thng you are collaborating on? yes!
  3 Kommentare
Mike Croucher
Mike Croucher am 29 Feb. 2024
Yes. Which version of MATLAB are you using? In R2023b, we got a very nice command line interface to git
Doug
Doug am 29 Feb. 2024
We have 2020b but may be updating soon.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Install Products finden Sie in Help Center und File Exchange

Produkte


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by