"git push" and "git push --tags" in the same command?

Nicolas Raoul picture Nicolas Raoul · Oct 16, 2013 · Viewed 20.7k times · Source

I usually run:

git push
git tag v4.7
git push --tags

Both the first and third operations connect to the server, which wastes time.
I want to make it faster by pushing only once. What command(s) would achieve this?
It is in a bash script, and needs to run fine in any branch, not just master.

Reading the manual, I don't think git push all is the solution:

--all: Instead of naming each ref to push, specifies that all refs under refs/heads/ be pushed.

--tags: All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line.

Answer

Kornel picture Kornel · Oct 16, 2013

The closest option may be:

git push --follow-tags

Push all the refs that would be pushed without this option, and also push annotated tags in refs/tags that are missing from the remote but are pointing at committish that are reachable from the refs being pushed.