Git Cherry-pick
Usage scenarios:
There are multiple branches locally, local_branch_a, Local_branch_b, ...
Commit on Local_branch_a on local branch, want to submit to local_branch_b on this,
At this time, if you are not afraid of mistakes, not too much trouble, of course, you can local_branch_b the last commit code in the rewrite to commit again.
But Git offers a better solution: Git cherry-pick <commit_id>
Specific Operating Procedures:
The first is the submission on the local_branch_a, with the submission of _id,
Then through the git log query to the submitted ID disease record,
Then switch to Local_branch_b,
Using Git Cherry-pick <commit_id>
After the command finishes checking the status,
If there is no problem and there is no conflict, it is tantamount to having executed a commit on the Loca_branch_b,
At this time, you can push directly on the local_branch_b.
code example:
Assuming now on the local_branch_a,
Git branch-vv
git status
git add <some_file>
Git commit-m "Comments"
git log
<commit_id>//Get commit_id and record
git checkout <local_branch_B>
Git branch-vv
git status
Git Cherry-pick <commit_id>
If there is no conflict, commit is already done.
If there is a conflict, you need to resolve the conflict first, you can merge manually, or you can use the Mergetool
After the conflict has been resolved, the execution
git add <merged_file>
Git commit-m "comments, use Cherry-pcik produce some conflicts, merge some file"
The execution is complete and you are ready to push.
Git Cherry-pick