Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get rid of unwanted changes in a git branch / pull request?

Common scenario: A contributor sends a pull request containing 1 or 2 useful changes plus a ton of (unwanted by me) whitespace changes made automatically by his IDE.

Of course I can tell him to adjust his IDE, and to use tools like GitX to stage specific changes before committing, but the damage is done; either he has to re-commit & force push, I have to accept all the changes, or one of us has to add an "undo" commit before merging.

Is there an easier way?

Ideally I could merge just like the commit process in GitX: I could unstage specific changes from the branch, and the tool would either auto-rewrite the commits or make an "undo" commit before merging.

like image 996
Steve Clay Avatar asked May 07 '26 13:05

Steve Clay


1 Answers

You get rid of the whitespace changes locally, the developer will see all the whitespace changes you didn't accept as changes against her version, and so on. Just misery spread all around.

The only way out is to agree on one whitespace style (perhaps enforced by the tools, or done by external tools before commiting). Uniformly for all.

like image 144
vonbrand Avatar answered May 10 '26 10:05

vonbrand



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!