bashgitshellcommand-linecommand-substitution

Get git commit SHA for use in command line utility


I want to run this command:

$ ionic-cloud build web --app-id=<APPFLOW APP ID> --commit=<GIT COMMIT SHA>

In order to do this I need to know my Git commit SHA. I know I can get this with:

git show -s --format=%H

Now how do I combine these things together to use in the command line? Should I make a shell script to do this?


Solution

  • If you want to include the output of the first command use:

    ionic-cloud build web --app-id=<APPFLOW APP ID> --commit="$(git show -s --format=%H)"