Code covered by the BSD License  

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

4.5

4.5 | 2 ratings Rate this file 24 Downloads (last 30 days) File Size: 2.17 KB File ID: #29154

A thin MATLAB wrapper for the Git source control system

by Manu Raghavan

 

28 Oct 2010 (Updated 13 Sep 2011)

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

| Watch this File

File Information
Description

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:
      This is not meant to be a comprehensive guide to the near-omnipotent
      Git SCM:
          http://git-scm.com/documentation

      Common MATLAB workflow:
   
      % Creates initial repository tracking all files under some root
      % folder
      >> cd ~/
      >> git init
    
      % Shows changes made to all files in repo (none so far)
      >> git status
   
      % Create a new file and add some code
      >> edit foo.m

      % Check repo status, after new file created
      >> git status
     
      % Stage/unstage files for commit
      >> git add foo.m % Add file to repo or to stage
      >> git reset HEAD . % To unstage your files from current commit area
    
      % Commit your changes to a new branch, with comments
      >> git commit -m 'Created new file, foo.m'

      % Other useful commands (replace ellipses with appropriate args)
      >> git checkout ... % To restore files to last commit
      >> git branch ... % To create or move to another branch
      >> git diff ... % See line-by-line changes
   
  Useful resources:
      1. GitX: A visual interface for Git on the OS X client
      2. Github.com: Remote hosting for Git repos
      3. Git on Wikipedia: Further reading

MATLAB release MATLAB 7.11 (2010b)
Other requirements Must have Git installed on the OS that MATLAB runs on: http://git-scm.com/download
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
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 Jan 2011 the cyclist  
03 Jul 2011 HaveF

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

20 Jul 2011 Mikhail

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

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.

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

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

08 Feb 2012 Matthew Arthington

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

Please login to add a comment or rating.
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

Tag Activity for this File
Tag Applied By Date/Time
source control Manu Raghavan 28 Oct 2010 10:53:36
git Manu Raghavan 30 Oct 2010 17:27:53
version Manu Raghavan 30 Oct 2010 17:27:57
revision Manu Raghavan 30 Oct 2010 17:28:00
distributed scm Manu Raghavan 30 Oct 2010 17:28:39
scm Manu Raghavan 30 Oct 2010 17:28:44

Contact us at files@mathworks.com