Get from Ico-github-logo

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

» Watch video

Highlights from
A thin MATLAB wrapper for the Git source control system

4.9 | 9 ratings Rate this file 24 Downloads (last 30 days) File Size: 188 KB File ID: #29154 Version: 1.10

A thin MATLAB wrapper for the Git source control system


Manu Raghavan (view profile)


28 Oct 2010 (Updated )

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

| Watch this File

File Information

A thin MATLAB wrapper for the Git source control system

Required Products MATLAB
MATLAB release MATLAB 7.11 (R2010b)
Other requirements Git:
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (20)
09 Jan 2017 David

David (view profile)

29 Oct 2013 Mark Mikofski

Mark Mikofski (view profile)

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

Find it here (

Comment only
10 Oct 2013 Sam

Sam (view profile)

18 Jul 2013 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?

Comment only
08 Jul 2013 Matthew Bergkoetter

10 Jun 2013 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.

06 Feb 2013 Alex Liberzon

26 Jan 2013 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.

02 Dec 2012 Stephanie Liu

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.

13 Nov 2012 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.

Comment only
03 Oct 2012 Kay-Uwe Kirstein

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.

Comment only
20 Sep 2012 Louis-Emmanuel Martinet

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...

Comment only
08 Feb 2012 Matthew Arthington

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

Comment only
01 Nov 2011 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".

Comment only
25 Aug 2011 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]);
elseif (status==128)
warning('Not a git repository');
error('git is not installed');

Comment only
21 Jul 2011 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.

Comment only
20 Jul 2011 Mikhail

Mikhail (view profile)

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

Comment only
03 Jul 2011 HaveF

HaveF (view profile)

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

Comment only
12 Jan 2011 the cyclist

16 Dec 2010 Timothy Hansell

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

12 Mar 2011 1.1

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

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

13 Sep 2011 1.2

Added instructions on pull requests

11 Feb 2013 1.3

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

29 Apr 2013 1.4

Changes from pull requests submitted on github

23 Nov 2014 1.5

Made a toolbox
Updated documentation URL.

16 Jan 2015 1.6

Change doc link

27 Jan 2015 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

17 Aug 2015 1.10

Title reverted

18 Aug 2015 1.8

Link to Github repo instead

Contact us