Reputation: 93
My question is about the gpg-agent command which performs caching for gpg keys and pass-phrases.
I want to know how to use it so that I can run multiple git tag -s commands in a script without having to enter my gpg pass-phrase each time.
The initial version of my script is something like this:
git branch -r | grep origin | grep pattern |while read BRANCH; do TAG=
basename $BRANCH
; git tag -s -m "tag $TAG release" "$TAG" "$BRANCH"; done;
I have two use-cases:
I am looking for the command line for gpg-agent to run and then the gpg command I need to run to get my pass phrase cached so that it is useable when I do a git tag -s
Upvotes: 4
Views: 1339
Reputation: 36
This can be accomplished by running gpg-agent
before running the script. For example:
$ eval $( gpg-agent --daemon )
$ for branch in $( git branch -r | grep PATTERN ); do
> tag="$( basename $BRANCH )"
> git tag -sm "tag $tag release" "$tag" "$branch"
> done
You will be prompted for your password for the first sign (unless gpg-agent had already been used prior to the first sign). If using the above method, be sure to kill the agent after you are done (e.g. pkill gpg-agent
).
More information on running the agent can be found here: http://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html
Upvotes: 2