Behave correctly while rebasing etc and mark tree as dirty