# checkout mybranchgit checkout mybranch
# reset it to f (currently includes a)git reset --hard f
# rebase every commit after b and transplant it onto agit rebase --onto a b
git cherry-pick my_branch # by branch namegit cherry-pick 1e038f108a130831f108329b1083a8139813fabc # by full hashgit cherry-pick 1e038f10 # by partial hash
# A. INCLUDING the beginning_commitgit cherry-pick beginning_commit~..ending_commit# OR (same as above)git cherry-pick beginning_commit~1..ending_commit# OR (same as above)git cherry-pick beginning_commit^..ending_commit
# B. NOT including the beginning_commitgit cherry-pick beginning_commit..ending_commit
# you cherry-pick all of their extra commits from their `peer_branch` onto# your `my_branch` (note: the 3 dots below are very important!)
git fetch origin peer_branch # get their latest changes from the remotegit checkout my_branch # ensure you're on your branch# cherry-pick their range of commitsgit cherry-pick my_branch...origin/peer_branchgit log # review the commits you just chery-pickedgit push # push your changes to the remote
# **your peer** does this
# peer fetches your branch named `my_branch` and forks their `peer_branch`# off of it
# they fetch your latest work from remote `my_branch` into their locally-stored# remote-tracking "hidden" branch named `origin/my_branch`# (note: you can see all locally-stored remote-tracking "hidden" branches# with `git branch -r`)git fetch origin my_branch# create `peer_branch` as a fork off of `origin/my_branch`, and check it outgit checkout -b peer_branch origin/my_branch
# Now they can add their changes and commits and `git push` to remote `origin`# as their own `peer_branch` when done.
# **you** do this to cherry-pick your peer's helpful changes they added to# your work
# you fetch their latest work from their branch named `peer_branch` on remote# `origin` into your locally-stored remote-tracking "hidden" branch named# `origin/peer_branch`# (note: you can see all locally-stored remote-tracking "hidden" branches# with `git branch -r`)git fetch origin peer_branch# ensure you are on `my_branch` (if you aren't already)git checkout my_branch# you cherry-pick all of their extra commits from their `peer_branch` onto# your `my_branch` (note: the 3 dots here are very important!)git cherry-pick my_branch...origin/peer_branch
git log # review the commits you just chery-pickedgit push # push your changes to the remote
// Go to "dev" branchgit checkout dev
// Get the commit id (1e2e3e4e1 here)git log --oneline
> ...> ...> 1e2e3e4e1 Remove Last Name field> ...> ...
2.将提交推送到“hotFix1”分支
// Go to "hotfix1" branchgit checkout hotfix1
// Get the commit (1e2e3e4e1) from "dev" branch to "hotfix1" branchgit cherry-pick 1e2e3e4e1
// verify changes are correctgitk
// push to "hotfix1" branchgit push