Let's say I have a master
and develop
branch. develop
has code that master
doesn't. I branch off of develop
and create feature
, write some new code, merge it into develop
(to put it on staging and test it). I then decide I want to merge feature
into master
, but includes everything from develop
that's not in master, which I don't want to merge right now. How can I make it so that feature
has the code I added, as if it was branched from master
, and not develop
? I've been reading a bit about rebase, and cherry-pick, but I can see any examples exactly like mine (where feature
has already been merged into develop
)
I would say
git rebase --onto master develop feature
and then merge that into master
git merge master
you may create intermediate branch names if you need.
Get the list of commit(s) from develop
branch.
git checkout develop
git log
and get the commit hash-number
. Sample commit hash-number
: commit 0ef6a22f4a4bd1dc4561dab413a9ff09780d18c0
After getting the commit hash(es). Checkout master and cherry pick the commits from develop
to master
one by one. Prefer to go from older commits to the newer, to avoid more merge conflicts.
git checkout master
git cherry-pick hash-number
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.