Personal-Heat-8980 · 2022-12-26 07:06
When I stage commits and then 'p' to push, there is an option 'e' for elsewhere. This brings up a list of local and remotes that contain old references I no longer have or use in the "magit-push-current" section. How can I clean up this list so it shows the /current and correct/ combination of local branches and remote repos? After much googling, I can' seem to find any guidance.
I have also reviewed all .git/config files to be sure they don't contain the older refs. I
Thanks in advance!
republic_of_mao · 2022-12-26 07:57
"y": Show refs -- gives you a list of local branches, remotes and remote branches, and tags.
"k" on any of these starts you down the road to deleting them ("discarding" in magit-speak).
7890yuiop · 2022-12-26 08:46
Refer to the `git-fetch` man page:
-p, --prune
Before fetching, remove any remote-tracking references that
no longer exist on the remote. Tags are not subject to
pruning if they are fetched only because of the default tag
auto-following or due to a --tags option. 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. Supplying --prune-tags is a
shorthand for providing the tag refspec.
See the PRUNING section below for more details.
-P, --prune-tags
Before fetching, remove any local tags that no longer exist
on the remote if --prune is enabled. This option should be
used more carefully, unlike --prune it will remove any
local references (local tags) that have been created. This
option is a shorthand for providing the explicit tag
refspec along with --prune, see the discussion about that
in its documentation.
See the PRUNING section below for more details.
Or alternatively, `git remote prune` or `git remote update --prune`:
prune
Deletes stale references associated with <name>. By
default, stale remote-tracking branches under <name> are
deleted, but depending on global configuration and the
configuration of the remote we might even prune local tags
that haven’t been pushed there. Equivalent to git fetch
--prune <name>, except that no new references will be
fetched.
See the PRUNING section of git-fetch(1) for what it’ll
prune depending on various configuration.
With --dry-run option, report what branches will be pruned,
but do not actually prune them.
update
Fetch updates for a named set of remotes in the repository
as defined by remotes.<group>. If a named group is not
specified on the command line, the configuration parameter
remotes.default will be used; if remotes.default is not
defined, all remotes which do not have the configuration
parameter remote.<name>.skipDefaultUpdate set to true will
be updated. (See git-config(1)).
With --prune option, run pruning against all the remotes
that are updated.
cradlemann · 2022-12-26 10:09
Thank you for this amazing comment, I'm also struggling from outdated remotes
Personal-Heat-8980 · 2022-12-26 22:04
Thank you for the answers. I found the solution which was different. However, your response started me on a different thought leading to the soln.
I forgot that I set up a .gitconfig in my home directory a while ago. In this file, I had refs listed that kept showing up. Once I cleaned up this file, everything looked good.
I setup the file to hold global values. I still use it, but now the refs are with the vcs controlled .git/config file. I use multiple branch names against multiple remotes.
Hope this helps others!