Patch Set 5:

I did some more tests and found that this exception occurs when I edit a class and then, while the selection is in the Java editor click the "Commit" button in the main workbench toolbar. 

To enable the git buttons in the main toolbar right click the toolbar area, click "Customize perspective...", "Command Group Availability", "Git".

The exception is thrown since at org.eclipse.egit.ui.internal.actions.CommitActionHandler.executePushCommand(CommitActionHandler.java:78) doesn't expect a TextSelection.