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
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).
Mark Mikofski (2020). JGit4MATLAB (https://www.mathworks.com/matlabcentral/fileexchange/41348-jgit4matlab), MATLAB Central File Exchange. Retrieved .
Shawn Pearce, the author of JGit has died. There is a go fund me for his wife and children. https://www.gofundme.com/shawn-pearce-memorial-fund
**Quick Tip:** Use `>> jgit update` to download the latest version of JGit. The older version is archived in the folder called `older-versions/` and the file `version` is updated with the latest version number. Then restart MATLAB for the update to take effect.
Another interesting mergetool is DiffMerge (http://www.sourcegear.com/diffmerge/) it has a standalone executable - select download from menu at left then select the Windows zip file and download/extract, start sgdm.exe - Voila! It's also available for other platforms. Unfortunately they a freemium model that has a registration pop-up, so this may not be the best option. Do you use JGit4MATLAB? Do you have any mergetool suggestions?
Another possible mergetool is WinMerge - http://winmerge.org/ - it also is available as standalone exe, select download tab and look for "binaries" and download/extract zip file. I actually like this one better, it has generate-patch and open conflicted file functions - wonder if it can interpret Git conflict markers? Do you use JGit4MATLAB? What mergetool(s) would you like to see integrated?
This is version 0.6 (Falcon)
+ It allows (subset of) Git syntax to be used.
EX1: jgit add file1 file2
EX2: jgit commit -m 'enter msg in single quotes'
EX3: jgit pull
EX4: jgit push origin feature
+ Bugs fixes.
+ `javaclasspath.txt` is now in prefdir instead of userpath (thanks Volker).
+ Merge conflicts also output *.BASE, *.LOCAL, *.REMOTE and *.orig for use in merge tools such as meld and p4m.
+ Documentation is now at http://mikofski.github.io/JGit4MATLAB/.
Please submit bugs to https://github.com/mikofski/JGit4MATLAB.
Just wanted to post an update - I have made some major improvements to JGit4MATLAB. Now it can use SSH passphrases (or not), and can pull, push and fetch. I put utilities in to change or view global config and to save your passphrase. Still more to come! Also check out new website: http://mikofski.github.io/JGit4MATLAB/.
See the recent post on JGit and JGit4MATLAB @ http://undocumentedmatlab.com/blog/jgit-matlab-integration/
download the latest JGit 188.8.131.52306101825-r by using<br/>
then restart matlab
Hi Muthu, Thanks for the comment. I have added a function, lowercase "jgit.m" one level up and in the same namespace as @JGit so you should be able to just use the command interface that you describe if you put the toplevel (JGit4MATLAB) on your path.
EG: if JGit4MATLAB is on your path, and this is your file structure:
.....\__etc. (other methods in class "@" folder)
then you should be able to call the functions without strings as in your examples:
>> jgit status
# On branch master
nothing to commit, working directory clean
>> jgit branch list
>> jgit checkout gitCheckout
>> jgit status
# On branch gitCheckout
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
# no changes added to commit (use "git add" and/or "git commit -a")
Is this what you are talking about? If not let me know, and thanks again for your feedback!
BTW: the @folder issue was resolved in the 2013-05-28 update.
MATLAB has nice feature of supporting both command and functional interface.
i.e. >> disp('hello-world')
%works as well as,
>> disp hello-world
You may want to improve the command interface to JGIT, since most of the arguments are strings, we don't need to call it explicitly that way.
Sorry, folks, I accidentally zipped this up wrong last time, skipping the @JGit folder which is kind of important. I've uploaded a new submission but in the meantime just unzip or copy the contents to a folder on your path called @JGit.
All commands that deal with remotes and that require authentication, EG: CLONE, FETCH, PULL, PUSH, will *only* work
* with SSH
* with *no* passphrase
* with keys in the openSSH format
* with keys and known hosts in $HOME\.ssh
Obviously remotes that do not require authentication will work fine. EG: public, read-only and local repositories.
SSH is very easy to set up.
1. Download puttygen (Intel x86) from this site:
Disregard the "Intel x86" business, it doesn't matter what processor you have or whether your os is 64-bit or 32-bit. Puttygen is a very mature well establish application that is used by many other applications, for example all of the TortoiseXXX scm clients use Putty, Plink and Pageant
This is the actual download here: (click to download then click to install)
2. create a folder called .ssh in your %USERPROFILE%. On Windows 7 this is
C:\Users\<your account name>
and on xp it is
C:\Documents and Settings\<your account name>
You can do this in matlab.
>> mkdir(fullfile(getenv('userprofile'), '.ssh'))
3. create a key using puttygen, this is fairly self explantory, and kind of fun, but do *not* set a passphrase; leave those fields blank!
4. using puttygen, find the conversion menu tab and export the key in the openSSH format to the .ssh folder you created earlier.
5. now copy and paste your public key to your remote repositories (Github, Bitbucket, etc.) as needed. Jsch, which is the ssh client that JGit uses should now work out of the box.
Unfortunately using https isn't possible with JGit4MATLAB. Sorry. but hopefully you'll love the excitement of using ssh key pairs!
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!