Sepideh Abadpour
Sepideh Abadpour

Reputation: 2598

How to set up Git source control for matlab?

This is the first time I'm using Github. I want to use it as a tool for sharing code and organizing the different versions of my code.
I've downloaded Git for Windows and installed. I've also installed Github Desktop as the GUI client. I'm studying ProGit book and GitHub Desktop Documentation to start.
Recently I'm coding with MATLAB for my thesis. So as the first step, I've started with Select or Disable Source Control System. But when I go to MATLAB > General > Source Control, there's only one option and that is none.
enter image description here

What should I do?


Edit:
enter image description here

Upvotes: 3

Views: 2312

Answers (2)

EscAbe
EscAbe

Reputation: 1

The screenshot which you shared tells me that you are running a MATLAB version prior to R2014b; those simply did not have Git integration yet. This was added in the R2014b release, see:

https://www.mathworks.com/help/releases/R2015b/matlab/release-notes.html#buikqh_-1

In those older releases MATLAB only supported MSSCCI compatible source control systems; I do not believe there is a MSSCCI compatible interface for Git.

In newer releases your preferences would show "Enable MathWorks source control integration" and that would then support Git (which might then require the further setup as from the other Answer).

Upvotes: 0

VonC
VonC

Reputation: 1327194

You would need to setup Git first with matlab.

That involves:

  • uncompressing the latest git archive anywhere you want (like PortableGit-2.7.0-64-bit.7z.exe uncompressed in c:\PortableGit-2.7.0-64-bit.

  • add c:\PortableGit-2.7.0-64-bit;c:\PortableGit-2.7.0-64-bit\bin;c:\PortableGit-2.7.0-64-bit\usr\bin to your %PATH%.

  • define the environment variable HOME to %HOMEDRIVE%%HOMEPATH%

  • launch matlab in a CMD session where PATH does reflect the paths mentioned above, and where HOME is set.

Typically, create a small senv.bat script with (assuming you did install git as I specified):

@echo off
set PATH=C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\

set GIT_ROOT=c:\PortableGit-2.7.0-64-bit
set PATH=%PATH%;%GIT_ROOT%;%GIT_ROOT%\cmd;%GIT_ROOT%\bin;%GIT_ROOT%\usr\bin"

set "MATLAB_ROOT=C:\Program Files\MATLAB\R2013b"
set PATH=%PATH%;%MATLAB_ROOT%;%MATLAB_ROOT%\bin;%MATLAB_ROOT%\runtime\win64;%MATLAB_ROOT%\polyspace\bin;

Open a CMD session, go to the folder where you put senv.bat, type senv.bat, then launch MATLAB from the same command line (I don't know the name of the MATLAB exe)

Upvotes: 1

Related Questions