JGit4MATLAB is a wrapper for JGit in MATLAB. It is meant to be used from the MATLAB command window.
Updated 14 Oct 2013

View License

JGit4MATLAB is a wrapper for JGit (http://www.eclipse.org/jgit/) in MATLAB. It is meant to be used in the MATLAB command window.

Download the full zip-file from MATLAB Central File Exchange, extract anywhere on your MATLAB path and type jgit. This will download the latest version of org.eclipse.jgit and edit your Java class path file called javaclasspath.txt in the MATLAB preferences directory, making a copy called javaclasspath.txt.JGitSaved of javaclasspath.txt if it already exists.

After this you must restart MATLAB for the changes to your MATLAB Java static class path to take effect.

Create your ssh keys using putty gen and convert them to OpenSSH format. If you set a passphrase, save it in %HOME%\.jsch-userinfo using

>> jgit saveSSHpassphrase <passphrase>

You can set and get global gitconfig name and email using

>> jgit setUserInfo <name> <email@address>

In general usage is the same as in Git. See http://git-scm.com/docs.

>> jgit <command> [<options>...] [<args>...] [--] [<args>...]

See all commands

>> jgit help

Get help for individual command

>> jgit help <command>

There are some built in aliases.
co = checkout, ci = commit, st = status, br = branch

Known issues:
There is no mergetool. When a conflict occurs on either pull or merge, the conflicting files will be saved as *.BASE, *.LOCAL, *.REMOTE and *.orig. Download Meld (https://code.google.com/p/meld-installer/) or P4Merge (http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools). Then use the *.BASE, *.LOCAL and *.REMOTE files to resolve the conflict and save the file using its name. As an alternative just use the Git conflict markers to resolve the conflict and save the file.

In order to mark the conflict as resolved, you must first add the file to the index. Then commit.

>> jgit add resolved-conflict-file1 ...
>> jgit commit

Unfortunately, you can not use the --all flag with commit to mark a conflict as resolved. This is a feature that I have not yet implemented issue #7 (see https://github.com/mikofski/JGit4MATLAB/issues/7).

Also there is no way to abort a merge without using the org.eclipse.jgit.api.Git reset command.

>> git = JGit.getGitAPI % get an instance of the JGit api
>> repo = git.getRepository % get an instance of the repository
>> state = repo.getRepositoryState % get the repository state
>> MERGING = org.eclipse.jgit.lib.RepositoryState.MERGING % an enumeration (a constant)
>> resetCMD = git.reset; % get a reset command object
>> HARD = javaMethod('valueOf','org.eclipse.jgit.api.ResetCommand$ResetType','HARD'); % a constant
>> if state.equals(MERGING),resetCMD.setMode(HARD).call,end % check if merging then abort

See issue #10 (https://github.com/mikofski/JGit4MATLAB/issues/10).


Report Bugs:


Cite As

Mark Mikofski (2024). JGit4MATLAB (https://www.mathworks.com/matlabcentral/fileexchange/41348-jgit4matlab), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Software Development Tools in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

fix bugs in pull and push. push should output message, for example if push rejected. Pull should save conflicting files for merging if conflict arises. add info on known issues

abbreviate summary

git commands are now parsed for jgit at the command line, ie you can type jgit log -10, or jgit checkout -- file.m

now with fetch and proper checks for new jar files, including UserInfoSshSessionFactory which lets you use passphrases with jgit.

SSH now works with passphrase! Update download site. Add push and fix many bugs.

add merge command, update to release 0.5, try new file structure

jgit command line function has better handling of numbers and boolean/logicals

correct zip file, did not have @JGit, listed methods as functions, oops! Also add command line wrapper that lets user call commands and args separated by strings.

add JGit.diff

now with checkout

add clone and branch

add init command, some more help, and also fix "typing JGit should install JGit 1st time" now it really does

improve log function, add some help

remove .git file, add log.m function