MATLAB and Git source control

34 views (last 30 days)
CoolNickname
CoolNickname on 27 Jun 2019
Commented: Bengisu Ozbay on 18 Dec 2023
Hi,
I'm struggling to set up Git Source Control in MATLAB and couldn't find a solution elswhere.
The option called "Use Git from the Windows Command Prompt" meanwhile changed in name though. For all other options not listed in the tutorial I chose the default one.
Now, I open MATLAB, right click in the "Current Folder" browser > Source Control > Manage Files.
I choose "Git" as source control integration, fill in the https path to my Git repository and select the path to an empty folder as my Sandbox. I klick retrieve and the files in GitHub will be downloaded to that specific folder. So far so good. But there is no .git folder created as I saw in other tutorials. If I want to add a new file to this folder, I right click on the file > Source Control > Add to Git. Now the circle is replaced by a black cross or plus. According to some articles and the official MATLAB video, I should right click on the file again > Source Control > Commit to Git Repository. And that's kind of the point where things get stuck. First, there isn't this option. I can only choose "View and Commit Changes" and the standard Git options. Well, I tried "View and Commit Changes", but npthing happens except MATLAB opening an invisible window in which I may be supposed to view and commit changes. But I can't see this window, I just see MATLAB flashing orange in the task bar. So that doesn't work. Then I tried the option "Push". Unfortunately that leads to an error "The target reference is already up to date no action required. refs/heads/master->refs/remotes/origin/master".
That's my problem and I'm hoping for your help.
What also bothers me is that MATLAB requires the entry of my Git username and password every time I want to conduct an action. Isn't it possible to avoid this?
Many thanks in advance for your help and best regards.
  3 Comments
CoolNickname
CoolNickname on 26 Feb 2020
Hi Aditya,
sorry for my late reply. Unfortunately not. I used manual backups instead. Not as elegant, but since I was the only one to work with the code, it did the trick for me.
Best regards.
Bengisu Ozbay
Bengisu Ozbay on 18 Dec 2023
Hello,
I was just having some similar having an invisible "View and Commit window" issue recently while trying to use MATLAB with git. When I close and restart my MATLAB I was able to see the "View and Commit window" where I can write commit messages and pick which one of the changed files to commit.
Regarding requiring the password since commiting changes does not require and password I just stick with that for the minor changes and push my commits daily or whenever I have a major edit.
I hope it will help anybody who may have the same problems in the future.

Sign in to comment.

Answers (1)

atervn2
atervn2 on 26 Feb 2020
Edited: atervn2 on 26 Feb 2020
Hello,
I had the same problem and I was able to get it somewhat working. When the invisible View and Commit Changes window "appeared", I right-clicked it in the taskbar and selected Maximize. This made the window appear and it mainly seems to work normally during the same Matlab session, but sometimes I have to do it again. Also, after starting Matlab again it I have to always maximize the window again when committing for the first time.
Hopefully this helps other people having the same problem! I have Win 10 and Matlab R2019a.
  2 Comments
CoolNickname
CoolNickname on 28 Feb 2020
Hi, many thanks for your feedback. Sounds very reasonable. Will try it out next time.
atervn2
atervn2 on 29 Feb 2020
No problem! Also, noticed yesterday that when you use projects, there is a "Source Control" section in the project ribbon menu. The "Commit" button there does not have the invisible window problem at all.

Sign in to comment.

Categories

Find more on Source Control in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!