171 TILs and counting...

Apply a patch file

Today I learned how to create and apply a patch file. If you want to quickly create patch a file from your current changes just run: git diff > mypatch.patch or if like you want just want specific changes then stage then and run: git diff --cached > mypatch.patch then to apply them all you need is git apply mychanges.patch Unfortunately if there are conflicts then 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. ...

Use winget to install Git for Windows with Unix tools

For years I’ve been using Chocolately for quickly installing git on new Windows and it’s pretty handy. Recently though I looked into doing the same with winget since it comes built into Windows now which makes it easier to just give to the command to a co-worker. One thing I always do though is enable the option to add the common linux tools to the path. With Chocolately you could just add the /GitAndUnixToolsOnPath param like this: ...

Auto add pull request reviewers

Today I learned that Azure DevOps lets you automatically include reviewers for a pull request if modifies certain files. This is very similar to Github’s code owners file with the key difference being that you configure it through the repo setting in Azure DevOps instead of committing a file. I find this very useful for example if you’re a Front End Architect who wants to be aware of any changes to the UI or if you’re a DBA who wants to review any database migrations. ...

 · 1 min ·