Move out the commit from the main loop

This is to make sure the last commit isn't rewritten inside the fast-export stream duplicating it.

TODO: This change will need to be tested.