Git: Cherry-pick a commit into a branch and resolve a merge conflict

Here’s the merge conflict message our merge master got when she tried to cherry pick my pull request (PR) to version 4.7 of the published OpenShift docs (lines , below).

openshift-cherrypick-robot commented 4 days ago • 
@theythemself: #29573 failed to apply on top of branch "enterprise-4.7":

Applying: [RHDEVDOCS-2614](https://issues.redhat.com/browse/RHDEVDOCS-2614) Define ClusterLogForwarder compatability Matrix
Using index info to reconstruct a base tree...
M	logging/cluster-logging-external.adoc
Falling back to patching base and 3-way merge...
Auto-merging logging/cluster-logging-external.adoc
CONFLICT (content): Merge conflict in logging/cluster-logging-external.adoc
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 [RHDEVDOCS-2614](https://issues.redhat.com/browse/RHDEVDOCS-2614) Define ClusterLogForwarder compatability Matrix
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Here, I start by deleting the enterprise-4.7 branch (line ) because it had a previous unmerged commit sitting at the top of the pile. (In the future, I think I’ll avoid this by creating a working branch off of the enterprise-4.7 branch.)

[memyself@memyself openshift-docs]$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'upstream/master'.

[memyself@memyself openshift-docs]$ git branch -D enterprise-4.7
Deleted branch enterprise-4.7 (was 803d05ddd).

Next, I create a new enterprise-4.7 branch that tracks Red Hat’s upstream repo (line). I don’t track my forked copy of the repo, origin, because it has that previous unmerged commit sitting at the top of the pile. (Again, there are other better ways to deal with that problem, I’m just sharing the one I used here.)

[memyself@memyself openshift-docs]$ git checkout --track upstream/enterprise-4.7
Branch 'enterprise-4.7' set up to track remote branch 'enterprise-4.7' from 'upstream'.
Switched to a new branch 'enterprise-4.7'

I fetch the latest changes from upstream and use status to verify that my branch is up to date.

[memyself@memyself openshift-docs]$ git fetch upstream
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 6 (delta 4), reused 5 (delta 4), pack-reused 0
Unpacking objects: 100% (6/6), 1.22 KiB | 1.22 MiB/s, done.
From github.com:openshift/openshift-docs
   335951a8d..0f6dbceae  enterprise-4.5 -> upstream/enterprise-4.5

[memyself@memyself openshift-docs]$ git status
On branch enterprise-4.7
Your branch is up to date with 'upstream/enterprise-4.7'.

nothing to commit, working tree clean

I go to the pull request with the failed cherry pick and copy the hash of the commit. I always squash commits so each pull request has only one commit.

I cherry pick that commit into the 4.7 branch. The merge conflict on line 5 is expected.

[memyself@memyself openshift-docs]$ git cherry-pick 3cad05d66d11c2d38a08322222f6c9dcbfc839ab
Auto-merging modules/olm-mirroring-package-manifest-catalog.adoc
Auto-merging modules/cluster-logging-deploy-console.adoc
Auto-merging modules/cluster-logging-deploy-cli.adoc
CONFLICT (content): Merge conflict in modules/cluster-logging-deploy-cli.adoc
error: could not apply 3cad05d66... RHDEVDOCS-2589 OpenShift Logging: Update any installation/upgrade specific information to use our new channels.
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

I check the status.

[memyself@memyself openshift-docs]$ git status
On branch enterprise-4.7
Your branch is up to date with 'upstream/enterprise-4.7'.

You are currently cherry-picking commit 3cad05d66.
  (all conflicts fixed: run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   logging/cluster-logging-exported-fields.adoc
	modified:   logging/cluster-logging-upgrading.adoc
	modified:   modules/cluster-logging-configuring-image-about.adoc
	modified:   modules/cluster-logging-deploy-cli.adoc
	modified:   modules/cluster-logging-deploy-console.adoc
	modified:   modules/cluster-logging-eventrouter-deploy.adoc
	modified:   modules/cluster-logging-log-store-status-comp.adoc
	modified:   modules/cluster-logging-updating-logging.adoc
	modified:   modules/cluster-logging-visualizer-kibana.adoc
	modified:   modules/olm-mirroring-package-manifest-catalog.adoc

In Atom editor (not shown here), I inspect the file that contains the conflict, modules/cluster-logging-deploy-cli.adoc. In it, I select the set of changes I want to keep. Then, I stage and commit the changes.

Back on the command line, I complete the cherry pick process.

[memyself@memyself openshift-docs]$ git cherry-pick --continue

I -f force push the changes to 4.7 to origin, which is my fork of the repo.

[memyself@memyself openshift-docs]$ git push -f origin enterprise-4.7
Enumerating objects: 27, done.
Counting objects: 100% (27/27), done.
Delta compression using up to 8 threads
Compressing objects: 100% (14/14), done.
Writing objects: 100% (14/14), 1.62 KiB | 1.62 MiB/s, done.
Total 14 (delta 13), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (13/13), completed with 13 local objects.
To github.com:rolfedh/openshift-docs.git
 + 803d05ddd...bcc5f087b enterprise-4.7 -> enterprise-4.7 (forced update)

Finally, on GitHub, in rolfedh/openshift-docs, I create the pull request to merge the commit into openshift:enterprise-4.5 from rolfedh:enterprise-4.5.

I’ll need to repeat this process and come up with a more complete set of screenshots.

Here’s a TLDR version of this blog post: Job aid: Git cherry-pick a commit and manually resolve a conflict
I use this short version to copy/paste commands into my terminal.

WordPress bug with highlighting lines in a code block

I discovered a bug. When you use the highlight lines property for code blocks as shown here…

Here, on the right, you see the “Highlight lines” property.

…the highlighting for the higher line numbers gets confused, as shown with lines 27, 39, 60 in the following screenshot.

Here, you see the highlighting on lines 27, 39, and 60 is wrong.

I’ve reached out to WordPress support and will let you know how it goes. I’ll try to file a bug for this.

[UPDATE] A WordPress happiness engineer created the following issue, which does an excellent job of analyzing and describing the problem: https://github.com/Automattic/wp-calypso/issues/50577

That might not be the right question | Seth’s Blog

“Where do you get your ideas?” The thing is, everyone has ideas. All the time, every day. Having ideas is part of the human condition. The right questions might be: Are you exposing yourself to new inputs and new situations, and challenging yourself to find more interesting ideas? Are you pushing the ideas you have further, making them more complete, turning them from hunches to notions to ideas to theories? Are you publishing your theories, sharing your reasoning and having your ideas collide with the real world in service of making things better?

That might not be the right question | Seth’s Blog

Let Gmail to sort your email

Gmail does a pretty good job of categorizing your messages. You can train it to do better.

animation of user moving email to correct tab in gmail
Drag the conversation to the correct tab and click Yes. Google confirms that it will do this for you in the future.

Primary tab

Move messages that you must review, respond to, or take action upon to the Primary tab.

Social tab

  • Move social network notifications to the Social tab.
  • These messages duplicate information in your social networks.
  • You should be able to select and delete everything in this tab without missing it.
  • For example, notifications from Facebook, Instagram, YouTube, TikTok, WordPress, etc.

Promotions tab

  • Move business offers and informational newsletters to the Promotions tab.
  • These messages promote products, services, people, and ideas you like but can safely ignore.
  • You should be able to select and delete everything in this tab without missing it.
  • For example, messages from Medium, Substack, Seth Godin, Walgreens, and Pocket.

Updates tab

  • Move important messages that you should see but usually do not need to act upon to the Updates tab.
  • These include automated automated paystub/billing/account/renewal notifications.

Forums tab

  • Move messages from message boards and mailing lists to the Forums tab.
  • You should be able to individually review and delete most of these messages.

Routinely unsubscribe from notifications and newsletters you don’t read. Some senders let you cut the frequency from daily to weekly or monthly.

Just as wild animals follow patterns that allow them to find adequate nutrition with the minimum expenditure of calories, information seekers follow patterns that allow them to find adequate information with the minimum expenditure of mental energy.

Mark baker, Every Page is Page One

How to learned to love my email inbox

Stop using your email as a holding pen for I should do’s and somedays.

Me, thinking to myself 🙂

My email inbox was a bottomless pile of messages seen and considered but not resolved. Having so many small choices increased my stress and reduced my ability to get things done.

Then, about a month or so ago, I heard “inbox zero” mentioned. I intuitively grasped the concept and set about finding a better way to process my email that reduces my effort, stress, and mess. It’s most obvious feature is that you have zero emails in you inbox.

Now (Feb 20th) I’ve been doing this for over a month and have gotten faster and better at it. Here’s my updated system, which I call zero inbox.

Before you practice zero inbox, train Gmail to sort your messages.

  • Scan and delete the messages that don’t matter.
    • In Gmail, this includes everything in your Social and Promotions tabs.
  • Scan and read the messages that matter. Do the following and then archive these.
    • Respond briefly, if needed
    • Forward messages that require attention or action from others. Include a note saying what you want them to notice or do.
    • If writing this note takes more than a few minutes, schedule a 10-minute videoconference or call with them.
    • Make to-do tasks from messages require further action. (Don’t let yourself start working on this things now.)

When you’re done every message should be deleted or archive. Your inbox should be empty.

It helps to know what your focus/responsibilities/goals/interests are. Don’t waste time on messages that fall outside of these. Don’t get sucked into email threads that don’t concern you or your work.

Conquering my to-do list

Recently, I explained how I implemented zero inbox and started capturing tasks in todoist. By pushing all of my tasks to one place, I cut down on the burden context-switching.

However, this new approach has created a new problem: a ballooning to-do list. Now, I must find a better way manage these tasks.

Fortunately, this article in the Harvard Business Review reminded me of the classic Eisenhower/Covey matrix for prioritizing tasks.

More urgentLess Urgent
More importantDo it nowSchedule it soon
Less importantDivide & conquer, or delegateDelete it, say “No,” or toss
it in the “someday” folder
My adaptation of the task prioritization matrix from Eisenhower, Covey, and the HBR article.

I’ll let you know how it goes.

How I create my to-do list in todoist

Recently, I wrote about zero inbox, my hack for getting rid of email stress and mess. I also mentioned that it depends on having a to-do list that can link back to your email messages.

A few years ago, I started using the free version of Todoist, an elegant and dependable app developed by a Germany-based software company. I was so pleased that I upgraded a year or so ago to their Premium version for $3/mo, billed annually.

Getting the most out of my to-do list requires a little skill and effort. Here’s how I add tasks to todoist:

  • Using the todoist extension in Chrome, I create an item for (almost) every task I encounter. The extension makes it easy to link to an email message or browser tab that’s open.
  • I avoid creating duplicate to-do items for tech docs deliverables I’m already tracking in an enterprise tool, like Jira or Bugzilla. Duplicates double or triple the amount of maintenance work I have to do.
  • For tasks I’m already tracking in enterprise tools, I create an umbrella task like “Work on the top priority item in Jira.”
    • Because this work is my highest priority, I type “p1” as a keyword in the item’s description: Todoist highlights the task with a red checkbox and moves it to the top of my to-do list.
    • I also mention the “every weekday” keyword, so Todoist makes this item a recurring task.
    • Finally, I click “Add website as task” so Todoist includes a link to Jira in the to-do item. This helps me reduce the number of open tabs in my browser, so I’m more productive.

zero inbox

Recently, I started practicing zero inbox. I didn’t read any specific how-to articles or books, I just implemented it based on these two principles:

  • DON’T USE YOUR EMAIL AS A TO DO LIST.
  • MESSAGES: DELETE, ARCHIVE, OR DEAL WITH THEM.

A quick search for “zero inbox” turned up this article and a 2007 Google TechTalks video on YouTube featuring Merlin Mann:

Inbox Zero – Merlin Mann – 2007

Merlin’s approach is a more nuanced (and probably more efficient) than mine. My approach is simpler:

  • I CHECK EMAIL between tasks and scheduled work periods.
  • I DELETE messages that have no informational value.
  • I ARCHIVE messages that seem to have some informational value. If the topic comes up in the future, I can search for it.
  • I DEAL WITH IT by replying to the message, adding a task to my to do list, and archiving the message. The to do task is linked to the archived email message.

This system works for me. It reduces my stress, mess, and effort.