[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.
If these fields aren't intended to be modified, please make them `final`.