I have a range of commits of another whose modifications I would like to import in my current branch without creating the commit.
I have seen that the cherry-pick
command has the option -n
to avoid commits. However, when conflicts arise, I do not know how to solve them since with cherry-pick normally one does git add
and then git commit -c <hash>
.
Is there a way to import the modifications introduced by these commits into the current branch without committing?
I was thinking about creating a patch somehow but I do not know if that's even possible.
The git cherry-pick -n
route sounds like a good plan.
When conflicts arise, solve them and add your resolutions, then git cherry-pick --continue
instead of committing.
You'll end up with a modified index resulting from the cherry-picks and resolutions. At this point you'll be able to inspect/modify/commit as needed.
That being said, even if you had committed the cherry-picks, you still could achieve the same final state with a git reset --soft <hash>
afterwards, where <hash>
is the pre-cherry-picks position of the branch.
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.