How to make a new commit with same changes except one?

84 Views Asked by At

I'm working in my own branch. I made a commit and a push (and pull request to master) that had all the changes / hunks that I wanted plus one more change that I didn't want. I want to basically undo that commit and have all those same changes (except for that one change I don't want) in my working copy so I can stage and commit again with all of those same changes except that one (a .rej file). Thanks!

1

There are 1 best solutions below

1
On BEST ANSWER

There are multiple options here.

  1. If you are the only person working on this branch, you can reset your local branch, re-commit with only the files you want and then force push it.
  2. If other people are working on your branch too, it is better to abandon your current pull request and create a fresh one. Just create a new branch, add correct files and create a pull request from that.
  3. The third option is adding a commit which removes that extra file. This would be your only option if the commit was in master (as you cannot force push to master branch) but otherwise, the commit will be an extra commit and could confuse your colleagues on why the file was added and removed in short amount of time.