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

조회 수: 10 (최근 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 CenterFile Exchange에서 Source Control Integration에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by