Git: Ensure documents are saved before executing destructive calls

Change-Id: I9ec0ae0ff6a1b70e5d4c322dbf2e53be57e3009f
Reviewed-by: Petar Perisin <petar.perisin@gmail.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>