MATLAB git on the command window

I use MATLABs git support in the development of my code, often fixing, pushing and all standard version control elements.

However, I used only the MATLABs user interface, which basically works by right-clicking on a folder and navigating through the menu until the right choice is found (see the figure below).

Is there a way to make MATLABs command windows run git commands instead of navigating through the menus each time?

enter image description here

+6
source share
2 answers

You can use the command line command line ! for git commands in MATLAB. For instance:

 !git status !git commit -am "Commit some stuff from MATLAB CLI" !git push 

For this you need git for your work.

+4
source

I like to impose the following function on my path:

 function varargout = git(varargin) % GIT Execute a git command. % % GIT <ARGS>, when executed in command style, executes the git command and % displays the git outputs at the MATLAB console. % % STATUS = GIT(ARG1, ARG2,...), when executed in functional style, executes % the git command and returns the output status STATUS. % % [STATUS, CMDOUT] = GIT(ARG1, ARG2,...), when executed in functional % style, executes the git command and returns the output status STATUS and % the git output CMDOUT. % Check output arguments. nargoutchk(0,2) % Specify the location of the git executable. gitexepath = 'C:\path\to\GIT-2.7.0\bin\git.exe'; % Construct the git command. cmdstr = strjoin([gitexepath, varargin]); % Execute the git command. [status, cmdout] = system(cmdstr); switch nargout case 0 disp(cmdout) case 1 varargout{1} = status; case 2 varargout{1} = status; varargout{2} = cmdout; end 

You can then enter git commands directly on the command line without using ! or system . But this has an additional advantage, since you can also invoke the git command silently (without output on the command line) and with status output. This makes it very convenient if you are creating a script for an automatic build or release process.

+5
source

Source: https://habr.com/ru/post/1015026/


All Articles