File Exchange

image thumbnail

A thin MATLAB wrapper for the Git source control system

version 1.10 (188 KB) by

Use this exactly as you would use the OS command-line Git, but from within MATLAB

4.88889
9 Ratings

26 Downloads

Updated

A thin MATLAB wrapper for the Git source control system

Comments and Ratings (20)

David

David (view profile)

Mark Mikofski

Mark Mikofski (view profile)

Try JGit4MATLAB, works from the MATLAB command window, doesn't require Git installation.

Find it here (http://www.mathworks.com/matlabcentral/fileexchange/41348-jgit4matlab)

Sam

Sam (view profile)

Sam Abbott

I'm having some trouble setting up this wrapper:
I have downloaded the submission to the MATLAB path and Git is installed on my system however I am getting the error message saying that Git is not installed. Any ideas why?

David

David (view profile)

This is a great addition to allow better integration of git with Matlab. However, I am having an issue with Matlab x64 on windows XP x64 and git 1.7.11.msysgit because from within matlab if I call up the git gui the control is never handed back to the Matlab prompt and the session freezes. Using the system escape (!) I was able to spawn a new process using (&) to handle this. However, the problem reappears with this utility. I can probably re-implement my work around but I would prefer to understand why control is not handed back to come up with a better solution.

Tyler

Tyler (view profile)

There might be an issue with using this wonderful utility to upload to a remote git repository using https. (on a mac) Git push uses curl to send the files to the repository (e.g. bitbucket) but the version of libcurl included in the MATLAB application bundle doesn't support https. To address this issue, just rename the included libcurl to something else (i.e. libcurl.old) and copy the newest version easily available from someplace like MacPorts. Make sure you add +ssl when getting the latest version of curl from MacPorts (sudo port install curl +ssl). This will then allow you to call git push to an https remote repository from inside the MATLAB command line.

I am new to git, and it is very usefule when control matlab project version.
one thing is, I need to use (git commit -m "new change in foo.m") to make it work in Linux.

Manu Raghavan

Manu Raghavan (view profile)

@Kay-Uwe Kirstein,

Certain git operations page the output text stream. Shelling out with the system call causes this to hang unless the output is piped. See my commit on 12 Mar 2011.

I have implemented a similar wrapper by myself and I am just wondering why are you piping the output thru 'cat' or 'type'?

@Luis-Emanual: using double-quotes (") instead of single-ones (') should work.

Hi,
commit is not working for me, because the ' is removed. Example:
>> git commit -m 'Created new file, foo.m'
error: pathspec 'new' did not match any file(s) known to git.
error: pathspec 'file,' did not match any file(s) known to git.
error: pathspec 'foo.m' did not match any file(s) known to git.

Because the system function receives:
git commit -m Created new file, foo.m

I don't understand why it is working for you guys...

I agree with Matt, setting to prog to 'cat' makes this work properly.

Matt

Matt (view profile)

It looks like for MsysGit (v1.7.7 anyway, on XP), that the git command and arguments should be piped to cat, not type.

So if you're having some difficulties on Windows - in the form of an error message about incorrect syntax - try removing the "if ispc" conditional block at line 69 and setting the value of "prog" to "cat".

John Stowers

This works better for me on linux

[status,i_] = system('git status');

% if git is in the path this will return a status of 0 or 128
% depending on whether we are sitting in a repository or not
% it will return a 1 only if the command is not found

if (status==0)
    % call the real git with the arguments
    arguments = parse(varargin{:});
    [i_,result] = system(['git --no-pager ',arguments]);
    disp(result)
elseif (status==128)
    warning('Not a git repository');
else
    error('git is not installed');
end

Manu Raghavan

@Mikhail, the shell-out operator '!' cannot capture outputs of shell commands, which is relevant for some operations, like knowing if git is even on the path.

Using the SYSTEM command over the ! operator also fixes issues related to multi-page scrolling views, like looking up git help operations.

Mikhail

Mikhail (view profile)

How is it different from !git init, !git status etc?..

HaveF

HaveF (view profile)

Does it can be used in Windows? when use MSysGit? Maybe not

the cyclist

This is a very good little utility.
I've found it useful on both windows and Mac OS X.

Updates

1.8

Link to Github repo instead

1.10

Title reverted

1.7

% v0.5, 22 January 2015 -- TP: Suppressed printing of ans before
% git command output
%
% v0.6, 26 January 2015 -- HG: Add path to git

1.6

Change doc link

1.5

Made a toolbox
Updated documentation URL.

1.4

Changes from pull requests submitted on github

1.3

I'm linking out to the original blog post I wrote for this, so that I can update content more regularly.

1.2

Added instructions on pull requests

1.1

v0.3, 12 March 2011 -- MR: Fixed man pages hang bug using redirection

Contributors: (MR) Manu Raghavan, (TH) Timothy Hansell

MATLAB Release
MATLAB 7.11 (R2010b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video