4.875

4.9 | 8 ratings Rate this file 51 Downloads (last 30 days) File Size: 2.21 KB File ID: #29154

A thin MATLAB wrapper for the Git source control system

by

 

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
Description

Detailed documentation for this utility is available here:
http://raghavan.info/blog/2010/10/30/make-matlab-git-play-well-together/

If you have modifications to this file that you'd like to share, I welcome them. Please follow the instructions on issuing a pull request at the main repo to do this:

https://github.com/manur/MATLAB-git

--
A thin MATLAB wrapper for Git.

  Short instructions:
      Use this exactly as you would use the OS command-line verison of Git.

  Long instructions are:
      See: http://raghavan.info/blog/2010/10/30/make-matlab-git-play-well-together/

MATLAB release MATLAB 7.11 (R2010b)
Other requirements Must have Git installed on the OS that MATLAB runs on: http://git-scm.com/download
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (19)
29 Oct 2013 Mark Mikofski

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

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

10 Oct 2013 Sam  
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?

08 Jul 2013 Matthew Bergkoetter  
10 Jun 2013 David

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

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

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

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.

20 Sep 2012 Louis-Emmanuel Martinet

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

08 Feb 2012 Matthew Arthington

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

01 Nov 2011 Matt

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

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]);
disp(result)
elseif (status==128)
warning('Not a git repository');
else
error('git is not installed');
end

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.

20 Jul 2011 Mikhail

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

03 Jul 2011 HaveF

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

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.

Updates
12 Mar 2011

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

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

13 Sep 2011

Added instructions on pull requests

11 Feb 2013

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

29 Apr 2013

Changes from pull requests submitted on github

Contact us