Search code examples
gitidephpstorm

PhpStorm GIT custom automation


I often use a git command like this in the PhpStorm console:

git add --all && git commit -m "fix the config publishing" && \
git tag -a v1.0.4 -m "fix the config publishing" && git push

I'd like to make it more convenient so that it would be a button opening a popup with 2 inputs: comment and tag. The corresponding parts of the command from above would be populated from the popup's inputs and then the command would be executed.

Do you guys know if this is possible in PhpStorm?

I know PhpStorm offers some git GUI, but it doesn't seem usable to me. Multiple complex dialog etc, whereas I only want to push all the changes assigning a tag, that's why the custom popup needed.


Solution

  • Note that you can achieve a similar convenient use case even without the use of "External tool" in your IDE, but simply through a script.

    If that script is called git-xxx (for instance git-actp, for add-commit-tag and push), it can be a simple bash script:

    #!/bin/bash
    tag=$1
    shift
    comment="$@"
    git add --all
    git commit -m "${comment}"
    git tag -a ${tag} -m "${comment}"
    git push
    

    If that script is anywhere in your $PATH or %PATH% (it works on Windows too), you can call it with:

    git actp v1.4.0 my comment with multiple words
    

    No need to fill out fields.