This flag enables progress reporting even if not attached to a terminal, regardless of -quiet Now we can refuse all such clobbering, whether it would happen by clobbering a local tag with " tag", or by fetching it from the remote with " fetch".Progress status is reported on the standard error stream by default when it is attached to a terminal, unless -quiet is specified. we refuse to clobber any existing tags unless " -force" is supplied. This also makes it nicely symmetrical with how " tag" itself works when So this change implements suggestion #1 from Jeff's 2011 E-Mail, " fetch" now only clobbers the tag if either " +" is provided as part of the refspec, or if " -force" is provided on the command-line. (See " In Git, how do I sync my tags against a remote server?") We could namespace our tags per-remote and not locally populate refs/tags/*, but as with my 97716d2 (" fetch: add a -prune-tags option and fetch.pruneTags config",, Git 2.17) it's easier to work around the current implementation than to fix the root cause. The current behavior doesn't make sense to me, it easily results in local tags accidentally being clobbered. Changing this behavior has been discussed as early as 2011. That commit and the rest of the history of " fetch" shows that the " +" ( -force) part of refpecs was only conceived for branch updates, while tags have accepted any changes from upstream unconditionally and clobbered the local tag object. Tags need not be pointing at commits so there is no way to See the git-fetch-script code in fast_forward_local() with the comment: This changes the long-standing behavior of " fetch" added in 853a369 (" Multi-head fetch.",, Git 0.99.5).īefore this change, all tag fetches effectively had -force enabled. Should clobber a local tag of the same name. (Merged by Junio C Hamano - gitster - in commit d39cab3, ) fetch: stop clobbering existing tags without -forceĬhange " fetch" to treat " +" in refspecs (aka -force) to mean we See commit 0bc8d71, commit ae6a470, commit fe802bd, commit 8da6128, commit d931455, commit 6b0b067, commit 253b3d4, commit f08fb8d, commit 8cd4b7c () by Ævar Arnfjörð Bjarmason ( avar). " git fetch" was taught to forbid updates to existing tags without the " -force" option. The rules used by " git push" and " git fetch" to determine if a ref can or cannot be updated were inconsistent specifically, fetching to update existing tags were allowed even though tags are supposed to be unmoving anchoring points. In addition of scripting (with pure git commands) the number of bad tags, Git 2.20 (Q4 2018) offers an alternative to avoid having to get tags with the same name with a branch. Git branch -r -list 'origin/*' -format="%(refname:lstrip=3)" That gives you pure git commands: git tag -sort="refname" > tags The pattern ' origin/*' makes sure we are selecting the remote branches of the right remote repo. The format transforms a remotes/origin/aBranchName into aBranchName. No need to grep origin, sed or sort (unless a branch.sort config had been set): use a pattern and a format: git branch -r -list 'origin/*' -format="%(refname:lstrip=3)" no need to sort git tag: they are already sorted by default by refname, unless a tag.sort config had been set.īut to be on the safe side, use at least git tag -sort="refname" (no | sort needed).(Merged by Junio C Hamano - gitster - in commit d89db6f, ) See commit 560ae1c () by Samuel Maftoul (``). Instead of using | sort, both git tag and git branch have a -sort= option, with based on git for-each-ref field names and using a pattern.īy default, the default sort order, both for branches and tags, is already by refname.Īnd since Git 2.19 (Q3 2018), git branch supports a config branch.sort, like git tag already had a config tag.sort. Saeedgnu's answer is on the right track, but uses many additional shell commands.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |