If you want to use a patch approach then "git format-patch|git am" and "git cherry" are your options.Ĭurrently, git cherry-pick accepts only a single commit, but if you want to pick the range B through D that would be B^.D in git lingo, so git rev-list -reverse -topo-order B^.D | while read revīut anyway, when you need to "replay" a range of commits, the word "replay" should push you to use the " rebase" feature of Git. With cherry-picking or rebase -onto, do not forget it has consequences on subsequent merges, as described here.Ī pure " cherry-pick" solution is discussed here, and would involve something like: or cancel the all thing with a " git rebase -abort" (and put back the integration branch on the tmp branch)Īfter that rebase -onto, integration will be back at the last commit of the integration branch (that is " tmp" branch + all the replayed commits).or skip this patch, and instead run " git rebase -skip".either solve it and run " git rebase -continue".If there is any conflict when one of those commits is replayed: To " tmp" (which points to where integration was pointing before) up to " integration" (which points to the last commit you want to replay, from the working branch).after the parent of first_SHA-1_of_working_branch_range (hence the ~1): the first commit you want to replay.Git rebase -onto tmp first_SHA-1_of_working_branch_range~1 integration # Rebase the patchset onto tmp, the old location of integration Git branch -f integration last_SHA-1_of_working_branch_range # Move the integration branch to the head of the new patchset If your current branch is integration: # Checkout a new temporary branch at the current location (also, look for "Here is how you would transplant a topic branch based on one branch to another" in the git rebase man page, to see a practical example of git rebase -onto) Note: as of Git 2.9.x/2.10 (Q3 2016), you can cherry-pick a range of commit directly on an orphan branch (empty head): see " How to make existing branch an orphan in git".Ī rebase -onto would be better, where you replay the given range of commit on top of your integration branch, as Charles Bailey described here. This assumes that B is not a root commit you'll get an " unknown revision" error otherwise. See " Git create branch from range of previous commits?" as an illustration. If you want to pick the range B through D (including B) that would be B^.D (instead of B.D). If they're the wrong order the command will silently fail. In the " cherry-pick A.B" form, A should be older than B. " cherry-pick A.B" and " cherry-pick -stdin"), so did " git revert" these do not support the nicer sequencing control " rebase " has, though. Git cherry-pick" learned to pick a range of commits When it comes to a range of commits, cherry-picking is was not practical.Īs mentioned below by Keith Kim, Git 1.7.2+ introduced the ability to cherry-pick a range of commits (but you still need to be aware of the consequence of cherry-picking for future merge)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |