'Git: the branch received in the pull request is dirty. how to clean it including git history

I received a pull request, but this commit history in branch(origin/foo) is so dirty, for example:

  • It contains a commit named "test".
  • It contains a lot of Diff like garbage, for example, just an indent, changed Single quotation into double quotation, and so on.

So, I want to clean this branch and commit history. Here are some idea:

  1. clean up a lot of code in origin/foo, then commit.
  2. delete this branch(origin/foo), and I create a new local branch(bar) from the starting point of origin/foo.
  3. delete this branch(origin/foo), and clean up it in local branch(foo), then rebase it.

I think second is better, because it will not include some dirty code. However, I want to know a better way than these three option.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source