Tuesday 15 September 2015

git - How do I get commits from a merged and reverted PR into a new one? -



git - How do I get commits from a merged and reverted PR into a new one? -

to create long story short, in next situation:

a feature branch created, worked on while collecting 30 commits, , merged master. merge reverted through github's web interface (by creating new pr reverted effects of old one).

now, have fixed problems caused revert merge, , i'd create new pr both of 30 or commits original pr , couple of more fix.

i've based feature-fix branch on (unmerged) head of feature branch, committed couple of times more , pushed create pr - reason, pr picks new commits, not old ones.

how include old commits in new pr?

i have force access repo (we're using shared repo model) operations don't require force-push master ok.

simplified git history:

* [feature-fix] <-- branch want pull | * [master] | * [merge revert pr] * |\ | | * [revert pr] * |/ <-- first commit included in new pr github | * [merge pr] |/| * | [feature] <-- original pr came | | * | <-- want these commits, included in old pr, included * | in new pr too. | | * | <-- started work on feature here. first commit want include. \| * <-- mutual ancestor between `feature-fix` , `master`, far can see

if understanding correctly need following.

git checkout master git revert sha_of_merge_revert_pr git merge feature-fix

the key step reverting commit reverted merge. sha removed changes, preserved merge history why seeing new commits.

you can read more linus himself here

git github merge pull-request

No comments:

Post a Comment