How to really delete a commit from Git

I really wanted to remove a huge binary file from a Git repository that has been committed by mistake. I found a bash script on the internet but the data still remained in the .git directory.

After some changes I came to this solution that really worked for me. But do not try that at home, it might corrupt your data!

set -o errexit

if [ $# -eq 0 ]; then
    exit 0

if [ ! -d .git ]; then
    echo "Error: must run this script from the root of a git repository"
    exit 1

git filter-branch --prune-empty --index-filter "git rm -rf --cached --ignore-unmatch $files" HEAD

rm -rf .git/refs/original/ && git reflog expire --expire=now --all &&  git gc --aggressive --prune=now && git repack -a -d -l


JBoss Technologies 1 in Czech

I would just like to bring your attention to my recent blog post on JBoss. The target audience is the Czech JBoss Community, so the article is in Czech only.


Move a java keystore certificate to openssl

A very good article on moving a self-signed certificate from a Java keystore to an openssl based keystore. Just the last step is missing:
openssl pkcs12 -name my_alias -export -in test.crt -inkey test.key -out keystore.p12


Byteman plays with Drools

Due to my recent suspicion that there is a bug in Drools I needed to monitor its guts in detail. To be more specific, I needed to see what is in the working memory after execution of all rules.

Debbuger was not a good option since there were hundruds of invocations of the problematic part and I needed to get overview of quite a large amount of data. If I inly could store all the data for each invocation in a file and then grep through it.

But wait! Of course I can. Byteman will help me! The identified point in source code was execution of fireAllRules() in org.drools.common.AbstractWorkingMemory. Ideally, just before return from the method. So here is the corresponding rule:

RULE Debug fireAllRules
HELPER org.drools.planner.examples.tournaments.helper.BytemanHelper
CLASS ^org.drools.common.AbstractWorkingMemory
METHOD fireAllRules

Just a few notes to it:

  • ^ means to apply to child classes as well
  • $0 refers to this

As you can see there is a custom helper class to print the working memory content since Byteman rules are little bit limited in the supported Java syntax.

import org.drools.impl.StatefulKnowledgeSessionImpl;
import org.jboss.byteman.rule.Rule;
import org.jboss.byteman.rule.helper.Helper;

public class BytemanHelper extends Helper {
   protected BytemanHelper(Rule rule) {
   public void printWorkingMemory(Object obj) {
      StatefulKnowledgeSessionImpl session = (StatefulKnowledgeSessionImpl) obj;
      for (Object o: session.getObjects()) {

And now I was able to get some nice output of individual working memories! So the resulting bug is JBRULES-3337.

. .