Cherry Picking

Trying to push a new feature branch, you accidentally branch of staging instead of master. git cherry-pick can help in this case.

$ git checkout feature/paid-campaign-measurement

This branch has `develop` as its parent. It should have `master`.

$ git log --oneline
37ad159 Remove uneeded comment
f671fa7 Added logic for checking whether to insert code
cc746b3 Add static class for facebook tracking code
b04dc50 Merge branch 'fix/golden-state-warriors-logo'
37a0c7c Fixed warriors logo

This gets me a list of the last few commits. The first three are mine.

$ git status
On branch feature/paid-campaign-measurement
$ git checkout master
$ git pull origin master

I make sure I’m on the right branch.

I’m going to fix this with a cherry-pick. git rebase is another way to fix it – but I spent two hours thinking about the rebase this morning, and was too nervous to go through with it. cherry-pick, I know how to do.

git checkout -b feature/facebook-campaign-measurement

This creates a new branch with a pretty similar name.

git cherry-pick --help

Get my syntax, to be sure I know what I’m doing.

$ git cherry-pick cc746b3
[feature/facebook-campaign-measurement fae0a96] Add static class for facebook tracking code
 Date: Fri Jan 26 11:03:55 2018 -0800
 2 files changed, 42 insertions(+)
 create mode 100644 plugins/msgn/includes/MSGN/Analytics/Facebook.php
$ git cherry-pick f671fa7
[feature/facebook-campaign-measurement 4ad13a0] Added logic for checking whether to insert code
 Date: Fri Jan 26 12:12:28 2018 -0800
 2 files changed, 23 insertions(+), 1 deletion(-)
$ git cherry-pick 37ad159
[feature/facebook-campaign-measurement b705421] Remove uneeded comment
 Date: Fri Jan 26 13:57:44 2018 -0800
 1 file changed, 10 deletions(-)

I cherry-pick my three commits in the same order I made them.

$ git status
On branch feature/facebook-campaign-measurement
Untracked files:
  (use "git add <file>..." to include in what will be committed)


nothing added to commit but untracked files present (use "git add" to track)
$ git push origin feature/facebook-campaign-measurement
Counting objects: 27, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (27/27), done.
Writing objects: 100% (27/27), 3.14 KiB | 0 bytes/s, done.
Total 27 (delta 16), reused 0 (delta 0)
 * [new branch]      feature/facebook-campaign-measurement -> feature/facebook-campaign-measurement

Then I cancel the code review on my old branch and request code review on the new one.


Working with a WordPress site…

Working with a WordPress site where you have a lot of hardcoded image URLs, but the actual images aren’t in your repository.

One way to deal with the broken images is to use an nginx rule to rewrite the images url to a remote staging site.

Here’s my nginx configuration file, located at vagrant/www/{my-site}/provision/vvv-nginx.conf.tmpl:

server {
    listen       80;
    listen       443 ssl;
    server_name  {{DOMAINS_HERE}};
    root         {vvv_path_to_site}/public_html;

    error_log    {vvv_path_to_site}/log/error.log;
    access_log   {vvv_path_to_site}/log/access.log;

    set          $upstream {upstream};

    include      /etc/nginx/nginx-wp-common.conf;

	location ~* \.(gif|jpg|jpeg|png)$ {
		if ($uri ~ "^/wp-content/uploads/[^/]*/.*$"){
			set $rule_0 1$rule_0;
		if ($rule_0 = "1"){
			rewrite ^/(.*)$$1 last;

Note that the .tmpl file is used rather than the .conf file, and that the `location` block is within the server block.


Every company needs it’s own…

Every company needs it’s own special VVV configuration, and so far, it’s been a bitch to set it up every time. However, I succeeded, after several hours. Tom J Nowell helped me out with the last detail –

First day at As…

First day at As usual, there’s a lot of software to install. First is Thunderbird, so I can enjoy a nice separation between work and personal email.

Next, pritunnel for vpn’ing.

Git is hard

I keep on coming back to this SO answer:

How to check out a remote branc:

Get urls out of href



Strip classes out of html