[Refactor] Refactor git merge

1) Refactor git merge
2) Move tree diff to a Diff command.
3) Add more typing and cleanup

@devoncarew PTAL thanks.
indent