Anonymous avatar Anonymous committed ed1aadf

[PATCH] git fetch --tags

You can do

git fetch --tags <linus-kernel-repo>

and it should fetch all my tags automatically.

[jc: The original by Linus fetched and overwrote branch heads with
--all, which felt dangerous and wrong, so I removed it. Also this
version does not use any refs that resulted as --tags for later
merge. ]

Signed-off-by: Linus Torvalds <>;
Signed-off-by: Junio C Hamano <>;

Comments (0)

Files changed (1)

+	-t|--t|--ta|--tag|--tags)
+		tags=t
+		;;
-for ref in $(get_remote_refs_for_fetch "$@")
+# If --tags (and later --heads or --all) is specified, then we are
+# not talking about defaults stored in Pull: line of remotes or
+# branches file, and just fetch those and refspecs explicitly given.
+# Otherwise we do what we always did.
+reflist=$(get_remote_refs_for_fetch "$@")
+if test "$tags"
+	taglist=$(git-ls-remote --tags "$remote" | awk '{ print "."$2":"$2 }')
+	if test "$#" -gt 1
+	then
+		# remote URL plus explicit refspecs; we need to merge them.
+		reflist="$reflist $taglist"
+	else
+		# No explicit refspecs; fetch tags only.
+		reflist=$taglist
+	fi
+for ref in $reflist
     refs="$refs $ref"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.