I want to synchronize certain subset of custom refs from origin to the local copy:
git fetch --force --prune origin refs/x/1:refs/x/1 refs/x/3:refs/x/3
I need git fetch to delete local ref when the remote one is missing. However, git fetch fails when any ref is missing on the remote: fatal: couldn't find remote ref refs/x/... and the existing refs are not fetched.
Workarounds
- Fetch ref one by one, delete local ref on error. But it's slow for many refs.
- Append
*to refs and use--pruneparam:
Drawback is, that it may fetch unnecessary refs, too (likegit fetch --force --prune origin refs/x/1*:refs/x/1* refs/x/3*:refs/x/3*refs/x/11etc.)
Is there any better way how to make git fetch synchronize subset of remote refs?