JGit4MATLAB

JGit4MATLAB is a wrapper for JGit in MATLAB. It is meant to be used from the MATLAB command window.
945 Downloads
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.

Installation:
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>

Usage:
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).

Documentation:
http://mikofski.github.io/JGit4MATLAB/

Report Bugs:
https://github.com/mikofski/JGit4MATLAB/issues

References:
http://download.eclipse.org/jgit/docs/latest/apidocs/org/eclipse/jgit/api/Git.html

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
Categories
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
1.18.0.0

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

1.17.0.0

abbreviate summary

1.16.0.0

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

1.15.0.0

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

1.14.0.0

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

1.13.0.0

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

1.9.0.0

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

1.8.0.0

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.

1.7.0.0

add JGit.diff

1.6.0.0

now with checkout

1.5.0.0

add clone and branch

1.4.0.0

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

1.3.0.0

improve log function, add some help

1.2.0.0

remove .git file, add log.m function

1.0.0.0