Magit: push tag and commit simultaneously
Problem: To release a new version of some software, I had to bash out at least four Magit commands in sequence:
- Commit.
- Tag the commit.
- Push the commit.
- Push the tag.
The pain point is between 3 and 4, because it's a network connection you have to wait for, as much as 1000ms round-trip. Now just imagine doing this repeatedly over a few minutes because of a series of hot-fixes.
OK, so let's streamline this. Looking on the web, I discover the gitconfig option push.followTags
, which would merge steps 3 and 4. However, it only applies to something called "annotated tags".
So I initially discard that solution and move on… but wait. OK, annotated tags sound like a PITA, but actually they can be automated, by Magit especially.
So let's use them. Add to ~/.gitconfig
:
[push] followTags = true
Then, stop typing t t
in Magit to tag, and instead type out t - a r
.
(This creates an annotated release tag. and "release tag" is just a Magit convenience to pre-populate the prompt.)
Next time you push, the tag is sent along.
What links here
- Unix