Page MenuHomePhabricator

In Git, clean up local tags that are no longer present in the remote
Closed, ResolvedPublic

Description

See http://stackoverflow.com/questions/1841341/remove-local-tags-that-are-no-longer-on-the-remote-repository

Currently, we don't delete tags from our clone, and neither does git fetch --prune. After doing a fetch, we should enumerate local and remote tags and remove any local tags that are no longer present in the remote.

Event Timeline

epriestley triaged this task as Normal priority.Aug 7 2012, 9:43 PM
epriestley added a project: Diffusion.
epriestley added a subscriber: epriestley.

According to this:

http://stackoverflow.com/a/16311126/821226

...we can do:

git fetch <remote> --prune --tags

...but only in "recent" versions of Git.

I merged https://github.com/phacility/phabricator/issues/679 here, which discusses a similar issue with hosted repositories. We're probably not cleaning up ref cursors properly, or not filtering them properly in the UI.

See also https://github.com/phacility/phabricator/issues/711. That report deals with reusing a callsign, and the new version of the repository picking up leftovers from the old repository.

I think we err on the side of caution when running bin/remove destroy and do not remove the working copy itself, but we should consider something like warning the user about this or moving it aside. This is made slightly complicated because DestructibleInterface does not currently have a way to transport warnings to the user about leftover resources.

chad changed the visibility from "All Users" to "Public (No Login Required)".Jul 3 2015, 5:20 AM
eadler added a project: Restricted Project.Jan 20 2016, 7:27 PM
eadler moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.
eadler moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Jul 4 2016, 9:16 PM

I believe this was resolved by T6878 or related work. In the modern codebase, we fetch with --prune and explicit refspecs, which is sufficient according to git help fetch:

--prune: ... However, if tags are fetched due to an explicit refspec (either on the command line or in the remote configuration, for example if the remote was cloned with the --mirror option), then they are also subject to pruning.

Locally, I deleted a tag in an observed remote and saw it properly deleted in the local working copy after an update, so this appears to hold empirically.