Cherry Picking commitsλ︎
Cherry Picking is a way to be specific about which commits from a branch are incorporated into another branch. Where as merging a branch into another would take the full commit history.
SPC g s to open magit status provides the
A Apply menu.
A with the point on any commit (or with commits selected in a list) allows cherry picking from the related branch.
A common use of cherry picking it to copy one or more commits from one branch and apply them to another branch.
Cherry picking may also be used as part of a pull request process, rather than merging the pull request directly, avoiding any unintentional commits that may be part of that pull request.
Cherries - comparing two branchesλ︎
Y to select cherries
Select the Cherry head - the branch containing commits (cherries) that are to be copied
Select the Cherry upstream - the branch that would receive the commits (cherries)
A list of commits, 'cherries', are show to help narrow down which commits could be cherry picked.
Awith the point on one of the cherries, or with one or more cherries selected, will start the Applying of commits
Find commits via list of branchesλ︎
l o in Magit Status will list the other branches.
Navigate to the branch and commit (or commits) to cherry pick. Use visual select state,
v to select multiple commits (
C-SPC in holy mode)
A starts the apply menu to start the cherry picking process.
A is also used to open the transient Apply menu, to continue skip or abort the cherry picking.
d to donate the selected cherry commits to another branch
Select the donate branch - the branch commits are to be copied to
If there are no conflicts, the commits are added to the branch. Push the changes,
P p, to a remote repository if relevant.
The Magit status buffer shows a cherry-picking progress section if the selected cherries (commits) cannot be automatically merged into the branch,
Files that contain merge conflicts will be listed under unstaged changes
RET to open file for editing in a buffer and resolve the conflicting change
SPC f s to save the file
SPC g s to return to the Magit status buffer
s on the file to stage any unstaged changes after editing the conflicting files
A to open the Apply action menu,
A to continue with the apply of cherries
Staged changes require committing, so continuing the Apply will open a commit message buffer
, , to confirm the commit
The cherry commits will be automatically committed, unless there is a conflict in another commit. Repeat the above steps until there are no further conflicts and all the commits are merged.
A sto skip over a commit that is proving to be overly challenging to resolve its conflicts
A ato abort and roll back to the state before cherry picking started, loosing all conflict edits
Diff 3 configurationλ︎
Diff 3 presentation of merge conflicts displays a common parent (if one exists) between the two changes in conflict.
Git configuration details how to add diff3 merge support along with many other useful settings.
Errors and Abortsλ︎
$ opens the Magit command log, showing commands run and errors that may have occurred, such as if commits are not applied or the Apply process aborts.