Job aid: Git cherry-pick a commit and manually resolve a conflict

This post is short version of Git: Cherry-pick a commit into a branch and resolve a merge conflict. Replace `upstream/enterprise-4.8` with whatever your target branch is.

I copy/paste these commands into my terminal.

git checkout master
git branch -D enterprise-4.8
git checkout --track upstream/enterprise-4.8
git status

Verify that “Your branch is up to date with ‘upstream/enterprise-4.8’.”

git cherry-pick <commit hash>

Go to the pull request that has the merge failure (e.g., like this example). Copy the commit hash. In the terminal, replace <commit hash> with the real one. Enter the command.

Ignore “CONFLICT (content): Merge conflict in <path/filename>

In Atom editor (or whatever), manually resolve the merge conflict.
Save and commit the changes as “Manual CP of RHDEVDOCS-<jira#> #<pr#>”.

git status

Confirm “Your branch is ahead of ‘upstream/enterprise-4.8’ by 1 commit.”

git push -f origin enterprise-4.8

Go to origin/enterprise-4.8 in GitHub and create the pull request with the following description.

https://issues.redhat.com/browse/RHDEVDOCS-2617
Previously merged as https://github.com/openshift/openshift-docs/pull/29491/files
[enterprise-4.8]

Copy the URL of this new PR and paste it to a comment in the Jira issue (e.g., in RHDEVDOCS-2617).

Rolfe DH

I've been writing since I had my first pen and a notebook. I've played with open-source software since I had my first computer. Now I apply these skills to making the world a better and more exciting place.

One thought on “Job aid: Git cherry-pick a commit and manually resolve a conflict

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s