185 TILs and counting...

You can backup your git stashes

As of Git 2.51 there is now a process for backing up your git stashes. The gist of it is there is now stash export command to export your stashes as a single reference and push them to a remote: git stash export --to-ref refs/stashes/my-stash git push origin refs/stashes/my-stash and then on another machine or a different clone of the repo: git fetch origin '+refs/stashes/*:refs/stashes/*' git stash import refs/stashes/my-stash Unfortunately this process isn’t that great for regular backups but can be useful if you need easily move lots stashes to another machine. For one off stashes though, it might be easier to create a patch file.

ICS end dates are exclusive

Today I learned that per the spec, the DTEND value in an ICS file is exclusive for all-day events. It makes sense but it’s not how most people think of date ranges. I ran into this while making a small node script that takes a json array of events and generates an ICS file. This has been the most convenient way I’ve found to quickly bulk create events in Google Calendar. The only issue is the multi-day events were coming up a day short. ...

 · 1 min · 

Apply a patch file

Today I learned how to create and apply a patch file with Git. If you want to quickly create patch a file from your current changes just run: git diff > mypatch.patch or if like me you just want specific changes then stage them and then run: git diff --cached > mypatch.patch then to apply the changes all you need is git apply mychanges.patch Unfortunately if there are conflicts then git will just give you an error: patch does not apply ...

Share git configuration in repo

Today I learned that you can share a git config file in a repository for easily sharing certain local config settings with your team. git config --local include.path ../.gitconfig This adds the following to your local config [include] path = ../.gitconfig and will load any config values set in that file. This has a couple advantages in that we only have to run a single git command and if we need to make future changes we only have to update the config file instead of requiring devs to run additional commands to get the update. ...

Quickly Fix A Misspelled Word

I just learned that you can have automatically fix a misspelled word with the top suggestion by typing: 1z= This is opposed to the regular z= command for opening the regular list of spelling correction options. Like Josh who I learned this from, I usually pick the first option so this is a bit more convenient.

Sudo for Windows

I just learned that Windows now has a builtin sudo command. You need to enable it from the Windows developer settings and then you use it similar to sudo on other operating systems. I’ve been using gsudo for some time and I still prefer as it overall has a nicer experience and is more fully featured, but if you’re looking for one less thing to install then the builtin sudo is decent. ...

Use skip-worktree to ignore modified files

Today I learned about the --skip-worktree command in git which will treat a file like it hasn’t been modified. This is useful if you have to modify a file locally but don’t ever want to commit it (config files are a common scenario). Like me, you may have seen --assume-unchanged used in this way but that’s not what it’s meant for since it’s “designed for cases where it is expensive to check whether a group of files have been modified”. As a result you’re likely to lose the changes you have made to those files. This post shows a good summary of the outcomes of common operations with each command. ...

Quickly react to recent message in Slack

Today I learned that you can react to the most recent message just by adding +. So you can type +:thumbsup: as the message it add it as a reaction to the most recent message instead of an individual message. You can also type ⌘⇧\ or ctrl⇧\ to open the emoji picker on the message.

 · 1 min · 

Move a line with :m

Today I learned that you can move the current line up or down with :m. :m +1 - moves down 1 line :m -2 - move up 2 lines I’m used to using dd followed by a movement and then p but I may try this alternate method.

Install SQL Server from the command line

I recently had to setup a new windows dev machine with a local instance of SQL Server and it turns out you can run it completely from the command line although it’s not very obvious how. Once you download the installer it will extract everything to a folder which contains the SETUP.exe executable which you can run from the terminal and pass all the options you want instead of clicking through the UI. ...