Configure Matlab for GIT on Windows
22 views (last 30 days)
Show older comments
Rocco Di Taranto on 5 May 2022
Answered: Rocco Di Taranto on 6 May 2022
I want to install Git on R2021b version, i am following the step which was given here git
To configure MATLAB® to use Git™ Hooks on Windows®, install Cygwin and add it to the MATLAB library path. Git Hooks are custom scripts that can be triggered by operations such as committing, merging, and receiving pushed commits.
- Download the installer from https://www.cygwin.com/. Run the installer.
- Open librarypath.txt. In the MATLAB Command Window, enter:edit(fullfile(matlabroot,"toolbox","local","librarypath.txt"))Add the Cygwin bin folder location to the end of librarypath.txt, for example, C:\cygwin64\bin.If you do not have permission to edit the librarypath.txt file, see Locate Native Method Libraries.
I do not have permission to edit the file, I am trying to follow instructions here Locate Native Method Libraries. But I am not able to solve the issue. Can anybody help me with this?
Andreas Apostolatos on 5 May 2022
The step of installing Cygwin and adding it to the MATLAB library path is just an optional step in case you want to use Git hooks with MATLAB. If you just want to use basic Git functionality with MATLAB, then installing Git and having it added to the Path environment variable is enough.
After installing Git, locate in your computer the git.exe executable. In my case this is installed in the following directory:
This directory then needs to be placed in the Path environment variable, see for instance the following screenshot,
To verify that this has taken effect, just open a Windows CMD Terminal and type the following command,
$ git --version
If you get the git version as output, then Git has been appropriately added to your Path environment variable. Just restart MATLAB and you should be able to use Git with MATLAB.
You may want to consider adding the following commands into a MATLAB startup.m file,
!git config --global core.longpaths true
git = settings().matlab.sourcecontrol.git;
git.KeyHasPassphrase.PersonalValue = true;
The first command allows files stored in long paths to be added to be Git-versioned while the other two let you to enter your passphrase only once per MATLAB session.
I hope this information helps.
More Answers (1)
Find more on Source Control Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!