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

6 ビュー (過去 30 日間)
Doug
Doug 2024 年 2 月 27 日
コメント済み: Doug 2024 年 2 月 29 日
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 件のコメント
Stephen23
Stephen23 2024 年 2 月 29 日
"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 2024 年 2 月 29 日
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.

サインインしてコメントする。

採用された回答

Mike Croucher
Mike Croucher 2024 年 2 月 29 日
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 件のコメント
Mike Croucher
Mike Croucher 2024 年 2 月 29 日
Yes. Which version of MATLAB are you using? In R2023b, we got a very nice command line interface to git
Doug
Doug 2024 年 2 月 29 日
We have 2020b but may be updating soon.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInstall Products についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by