oops! how to undo `git pull`

Today I did git pull when I really wanted to git merge --no-ff. Uh-oh. Luckily for me the fix was pretty easy. I just did git reset --hard and it worked out well because I hadn’t done any work since the last push. That meant the local and remote branches were pretty close, so I wasn’t undoing any work.

Just in case you do have more local commits that you want to save you can use git reflog to find the hash of the commit you want to revert to. Then you can run git reset --hard <whatever hash you selected above> And voila! You are back in business.

I found lots of info on this online, but this site was the simplest explanation of things for me.

shortcut magic – run rspec tests with a keyboard shortcut.

I’m still tweaking my screen layout in vscode a lot. One thing I really don’t like is that the terminal has to be fixed to the bottom. That means I can’t get much height out of it unless my code window is tiny. I played with turning my monitor, but that felt pretty bad for my neck and didn’t make me feel better about my layout. Last week I stopped using the vscode terminal and started using iTerm again. That was better, but now I needed to use my mouse or a bunch more shortcuts in order to switch to iTerm, press up to get the previous command, and then switch back to the code to start fixing. Then today I had a good idea!

Idea: use a system-wide keyboard shortcut to re-run the last command in the terminal.

It’s really simple: I set up an automator task that switches to iTerm, presses the up arrow, and then presses enter. I set the shortcut to be command f3, so now I can run my tests without taking my hands off the keyboard (and in one shortcut!) I also had to make sure vscode wasn’t using that shortcut. This is written in a funny little scripting language called applescript. It’s been baked into osx for forever and it’s fairly readable.

Applescript code block in automator
System prefs showing how to set a keyboard shortcut for an action

Now while I’m doing red-green-refactor I’m able to save time with fewer clicks. It’s a tiny example of ‘automating toil’, but it makes me smile whenever I save a second.

How to fix “rubocop failed with code=7” error in vscode

Today I was trying to get rubocop working with vscode right now and I wasn’t having much luck. I read one comment on a thread that mentioned a weird quirk about how you open vscode.

It said that if you open vscode from the terminal then it knows the correct ruby environment to run in, but if you just click on the app it doesn’t.

I have no idea if that is actually true, but I can say that the error goes away when I open code from the command line. Now I’m one step closer to squiggly green lines everywhere!