私は私の道の上に以下の機能を置くのが好き:
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
あなたはその後、!
またはsystem
を使用せずに、コマンドラインで直接のgitコマンドを入力することができます。しかし、gitコマンドを静かに(コマンドラインには出力せず)、ステータス出力でも呼び出すことができるという利点があります。自動ビルドまたはリリースプロセス用のスクリプトを作成する場合は、これは非常に便利です。
ああ。これはMathworksのどこかで文書化されていますか? –
Gitを特に使用するわけではありませんが、はいです:https://uk.mathworks.com/help/matlab/matlab_external/run-external-commands-scripts-and-programs.html もう1つの便利なコマンドは 'system'です。ステータスと結果を返すことができます: '[status、result] = system( 'git status')':https://uk.mathworks.com/help/matlab/ref/system.html –
私はaccidet私の他の質問:https://stackoverflow.com/questions/42271641/matlab-git-pullを解決します。どうかお気軽にお答えください。 –