Chris's Wiki :: blog/programming/GitUpstreamLimitedTracking Commentshttps://utcc.utoronto.ca/~cks/space/blog/programming/GitUpstreamLimitedTracking?atomcommentsDWiki2021-02-06T19:13:28ZRecent comments in Chris's Wiki :: blog/programming/GitUpstreamLimitedTracking.By Simon on /blog/programming/GitUpstreamLimitedTrackingtag:CSpace:blog/programming/GitUpstreamLimitedTracking:07759fb14d010bf76981bdb079af79cf69386abfSimon<div class="wikitext"><blockquote><p>Grafana's version branches are called things like 'v7.4.x', but it also has a few other branches that start with 'v' and we can't use a wildcard match of 'v[1-9]*'.</p>
</blockquote>
<p>You could just expand the wildcard manually in this case:</p>
<pre>
[remote "origin"]
fetch = +refs/heads/master:refs/remotes/origin/master
fetch = +refs/heads/v1*:refs/remotes/origin/v1*
fetch = +refs/heads/v2*:refs/remotes/origin/v2*
fetch = +refs/heads/v3*:refs/remotes/origin/v3*
fetch = +refs/heads/v4*:refs/remotes/origin/v4*
fetch = +refs/heads/v5*:refs/remotes/origin/v5*
fetch = +refs/heads/v6*:refs/remotes/origin/v6*
fetch = +refs/heads/v7*:refs/remotes/origin/v7*
fetch = +refs/heads/v8*:refs/remotes/origin/v8*
fetch = +refs/heads/v9*:refs/remotes/origin/v9*
</pre>
<p>Not nice but should work for you use case.</p>
</div>2021-02-06T19:13:28ZBy dozzie on /blog/programming/GitUpstreamLimitedTrackingtag:CSpace:blog/programming/GitUpstreamLimitedTracking:26f51701694d3599f4dd40764d16f239be22edd5dozzie<div class="wikitext"><p>@cks:</p>
<pre>
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
</pre>
<blockquote><p>(The plus sign is a bit magical but is probably okay here.)</p>
</blockquote>
<p>It's not magical (in my opinion) and it definitely is necessary here. Plus
sign, as you more or less know already, makes the <code>git fetch</code> invocation
that's running behind the scenes add <code>--force</code> option (only for selected refs,
of course).</p>
<p>When you're tracking content of a remote branch, git uses two steps approach:
the first step is to fetch and store all the remote state locally
(<code>refs/remotes/${name}/*</code>), and then uses this local image of remote
state to make a usable branch for actual work (<code>refs/heads/*</code>).</p>
<p>For your own local things plus sign of course is potentially dangerous (and
the same for push destinations), but for local image of a remote state, you
want it updated even if it's not a fast-forward update.</p>
</div>2021-02-06T13:38:08ZBy Aristotle Pagaltzis on /blog/programming/GitUpstreamLimitedTrackingtag:CSpace:blog/programming/GitUpstreamLimitedTracking:e0f878ad3acceb1902f2c0402fec8e7664dffe8cAristotle Pagaltzishttp://plasmasturm.org/<div class="wikitext"><p>The simplest way is to just do</p>
<pre>
git branch -Dr `git for-each-ref refs/remotes/origin --format='%(refname:short)'`
git fetch
</pre>
<p>which just blows away all of the remote branches from <code>origin</code> and recreates the ones you want. Since deleting a ref doesn’t delete the object the ref points to, that fetch will be a lightweight operation.</p>
<p>The only reason not to do this is if you wanted to preserve the reflogs for the branches you care about (which won’t matter to anyone who doesn’t know what that means).</p>
</div>2021-02-06T11:14:32Z