gcb
gcb

Reputation: 14554

sending a clean pull request, removing ancient commit

most of those questions are answered with "use rebase" :) so here is a concrete example so common cases can be better explained.

here is a situation (using letters instead of commit IDs) that I encounter often.

upstream/master:
A - B - C - D - E

origin/master:
A - Y - merge B - merge E

origin/feature
A - Y - merge B - merge E - M

Now i want to commit the changes made on M while working on origin/feature. but I am still not ready for the changes Y made on master, before i forked the feature.

The changes are easily mergeable as Y and M touch very different files.

Upvotes: 0

Views: 29

Answers (2)

Mudassir Razvi
Mudassir Razvi

Reputation: 1833

Also you could do:

On origin/feature:

$ git format-path -1

This will generate a path of just the M commit.

$git checkout upstream/master

$git am 0001-....

And you are done. All you are doing is taking the changes you made in M and applying it over upstream/master. Note: This is more or less similar to the answer of Andrew C but will not land you into any unknown trouble. Git rebase is powerful..but tricky!

Happy Gitting!

Upvotes: 0

Andrew C
Andrew C

Reputation: 14903

Presuming you are checked out to origin/feature, and want to get just commit M ready to push to upstream

git rebase --onto upstream/master HEAD~1

Upvotes: 1

Related Questions