If all of A, B and C have been submitted, you can consider git merge
:
git merge C --no-ff
# merge commit does not invoke the hook commit-msg, so
# if your Gerrit requires Change-Id and you want to push
# the merged commits for review, use amend-commit to generate it
git commit --amend
If at least one of them has not been submitted, use git cherry-pick
instead:
git cherry-pick HEAD..C --no-merges
HEAD..C
is equivalent to all the commits reachable from C and new to the current branch. --no-merges
excludes the merge commits among them. In an ideal case, merge commits don't involve conflicts and you don't need to cherry-pick them. If you do want to cherry-pick a merge commit, it's a bit annoying as you have to specify which parent to be the mainline.
If C and its ancestors are not available in the local yet, you need to fetch them first:
git fetch origin <refspec_of_C>
You can find the refspec of C on C's page. It's a ref like refs/changes/xx/xxxxx/x
. If C has been submitted to a branch, you can fetch the branch instead.