• Development,  Tech Tips

    Using PHPStorm for Git Diff and Merge tools (Mac)

    You love git-difftool, right? Of course! You also love PHP Storm, right? Of course! This easy procedure lets you use PHP Storm as your git-difftool.

    1. Open a project in PHP Storm
    2. Click Tools » Create Command-line Launcher…
    3. Edit your ~/.gitconfig file:
    4. Open the project in PHP Storm (see notes below)
    5. Open iTerm2 (or any other terminal emulator)
    6. Use git difftool as you normally would (e.g., git difftool .htaccess)

    Observations

    1. If you don’t have PHPStorm open when you try to use git difftool it doesn’t seem to work. I need to see if I can get it to open non PHP Storm projects, and/or I need to figure out how to switch on-the-fly between vimdiff and PHP Storm as my difftool.
    2. If you have PHP Storm open but the project itself isn’t open, “Annotate” is not available on right-click. Other functionality may be missing too. If you project is already open in PHP Storm you can annotate the diff!

    Thank you to JohnAlbin for the configuration snippet above.

  • Development,  Tech Tips

    Triggers in iTerm – Watching For Specific Strings

    I was recently performing a git-add in patch mode (  git add -p ) as I normally do, and realized there were a few lines I needed to make sure I didn’t commit. These lines were sandwiched between other lines that I did want to commit, and there were hundreds of changes, so it was hard to spot them. I wondered if iTerm2 had a way of highlighting or alerting when a specific word shows up in the terminal. To my surprise I found a “Triggers” section under the “Profiles » Advanced” tab in the settings for the app. iTerm2 really can do everything!

  • Development

    Automatically Stage All Deleted Files (Git)

    Tab-completion is a really nice thing that we often take for granted. While working with Git I’ve found that it becomes inconvenient to stage (add for inclusion in the next commit) removed files using git rm path/to/my/file.php. Tab completion doesn’t work on paths that no longer exist, so you have to manually type the path to the deleted item. The following snippet automatically stages ALL removed files.

    git ls-files -d -z | xargs -0 git rm --cached --quiet
  • Development

    Using Vimdiff with Git

    ​UPDATED: Check out “git difftool” which makes this process much cleaner (than the commands I previously had listed here). Basically, you can tell git what to use as a diff tool and it’ll let you do things like:

    Here is how I tell git to use vimdiff (these settings go in ~/.gitconfig):

    Here are some helpful commands that will get you started with vimdiff.

    • ctrl+w ctrl+w – switch windows
    • do – diff obtain (grab from the other side)
    • dp – diff put (move to the other side)
    • [c – previous difference
    • ]c – next difference
    • :diffupdate – (updates the diff)
    • :syntax off – syntax off
    • zo – open folded text
    • zc – close folded text

    Lastly, I suggest using the peaksea colorscheme when using vimdiff. It makes it much easier to see the changes and work with them.

    vimdiff
    The peaksea colorscheme with vimdiff