Unleashing gonsole 1.0, a Git Console for Eclipse
Over the last few weeks, Frank and I had some spare time. As summer hadn’t yet arrived in Germany, we decided to spend that time coding… What came out is Gonsole, a plug-in for the Eclipse IDE which provides a Git Console. The features that we originally intended to implement are now in place and thus we found it is the right time to release v1.0.
Though we documented the development progress in the gonsole weeks article series, we still found it might be worth to summarize the key features here:
- Integrated into Eclipse
- Content assist and usage hints
- A command history
- Optional integration with EGit
- Multiple console sessions
- Git included – no need to have Git installed
In order make the plug-in easy to discover and install, it is available from the Eclipse Marketplace. If you want to give it a try, just drag the icon into your Eclipse:
If you prefer, you can also install Gonsole directly from this software repository: https://rherrmann.github.io/gonsole/repository/
Integrated into Eclipse
The Git console is an extension to the Eclipse Console View. A new console session can be created with the ‘Open Git Console’ action.
The prompt (gonsole>
here) indicates the current repository, i.e. the repository to which the entered command will apply to. It can be changed with the use
command. This command requires either the absolute path to the .git folder of a repository or the name of a registered repository as its only argument.
Repositories can be registered through EGit (see below) or on the Team > Git Console > Repository Location preference page.
Furthermore the workspace is kept in sync. When commands change the work directory (e.g. checkout
, reset
or merge
) the affected workspace resources are refreshed to avoid stale resource state.
Content Assist
Ctrl+Space opens the content assist and shows usage information for the currently selected command.
Text that you have already typed or type while the content assist is open will filter the proposals that are shown.
Command History
Gonsole maintains a history of the most recently entered commands.
To bring up the history popup, you can use the same key as in the Unix shell: Arrow Up. As with the content assist, the list will be filtered as you type.
Integration with EGit
While Gonsole can be used standalone just fine, it is probably most valuable as an add-on for EGit. Therefore we offer an integration with EGit that can be installed optionally. If installed, the EGit Team menu shows an Open Console entry that opens a console session for the repository that the selected resource belongs to.
Furthermore, all repositories known to EGit can be specified as an argument in the use
command. If, for example, there is a repository ‘foo’ shown in the EGit Repository View, you can switch to it with use foo
.
Multiple Console Sessions
As mentioned earlier, the ‘Open Git Console’ action opens a new session each time. To switch between sessions, there is the ‘Display Selected Console’ drop-down.
To distinguish different sessions, the console view is labeled with the name of the repository that is currently in use. This allows you to operate on multiple repositories while keeping their work log separate.
Git Included
It is not necessary to have Git installed on your computer for the Git Console to work. The plug-in uses JGit, a pure Java implementation of Git, to interact with the repository.
More about Gonsole
Please see the plug-in’s homepage for documentation and further details. If you found a bug or if you would like something to be improved, please file an issue. Or even better, open a pull request that fixes what is missing or broken.
- Extras for Eclipse: Neon Update - 6. July 2016
- What’s the Difference? Creating Diffs with JGit - 16. June 2016
- Terminate and Relaunch in Eclipse - 19. April 2016
I am enjoying your product, I have noticed though when trying to use certain commands it says they are not found.
Example:
myproj> add –force .
Unrecognized command: –force
Thanks,
Keith
Hi Keith,
I am afraid the
--force
option is not supported. We use the JGit command line interface to process commands but it does not yet support all commands and options. You could ask the JGit maintainers to implement what you are missing and we will integrate it as soon as there is a release available.– Rüdiger
nice idea.
it’s possible to show available repositories in content assist for use command by ctrl space?
in real git console i see commit differences between my branch and master branch for ‘git status’:
On branch feature/abc
Your branch is ahead of ‘xyz/branch1’ by 1 commit.
(use “git push” to publish your local commits)
nothing to commit, working directory clean
it’s possible to show all action there running in egit in history of gonsole in form of git shell commands? e.g. if i change branch in egit i will see in gonsole history ‘egit: checkout feature/abc’.
best regards
frank
Hi Frank
thanks for sharing your ideas. What you suggest isn’t currently implemented. You may perhaps want to file enhancement requests in the gonsole issue tracker – and of course quality patches are also welcome :-)
Regards,
Rüdiger
Searching since a while for jgit and console.
Even this is not what I was really searching – it is a very good idea !
But I would assume, that you solved my problem ;-)
I am looking for jgit code to commit single files – not all changes in the folder.
Is there a snippet available ?
Or an approach how to solve this ?
I try to avoid plumbing – but currently I see no solution.
Thanks in advance
Christoph
Christoph,
this is not a Q&A forum. Please use the JGit forum or stackoverflow for future requests.
Nonetheless, let me try to answer your question. In order to commit files with git, you need to add them to the index first. The commit command will then form a commit of all the files from the index.
To add files to the index, in JGit, use the
AddCommand
like this:git.add().addFilepattern( "myfile.txt" ).call();
Despite its name,addFilepattern
can also be used to add single files.Once the index is in the right shape, use
git.commit().setMessage( "commit a single file" ).call()
to actually commit the changes.Regards,
Rüdiger
Hi, i know pull command isn`t supported too ¬¬
Right, JGit’s command line interpreter currently doesn’t support ‘git pull’.
You may want to file an enhancement request in the JGit bugzilla: https://eclipse.org/jgit/support/ to bring this to the attention of the JGit maintainers and eventually get implemented.
As soon as the feature is released with JGit, we can include the new version of the library.