git tip: fetching other branches from a shallow single-branch clone

19 views
Skip to first unread message

Matt Wilkie

unread,
Nov 19, 2019, 1:04:16 PM11/19/19
to leo-editor
For some time I've been championing the use of git "shallow clones" when working with Leo in order to dramatically speed up new clones. There's a side effect though: you don't get any information about the branches which have current activity but weren't named when creating the shallow clone (unless you use --no-single-branch option, which I often forget).

Here's a simplistic-but-works bash remedy (for Github repos only, see this Stack Overflow thread for background):

export URL=https://github.com/leo-editor/leo-editor/branches/active
curl $URL
> x.html
printf
'\n-- Commands to add the remote branches to the fetch list:\n'
grep
'data-branch-name' x.html | sed -r 's/^.*data-branch-name="(.*?)"(.*$)/git remote set-branches --add origin \1/'
printf
'\n-- Modification dates for these branches:\n'
grep
'time-ago' x.html | sed -r 's/^.*datetime="(....-..-..).*$/\1/'

The script doesn't add the remotes, just tells you what commands to run in copy-pastable form. After adding the remotes update your local status info with `git fetch`.

For bash scripts on on Windows I use GitExtensions which comes with the MingW bash shell; see the [console] panel.

-matt
Reply all
Reply to author
Forward
0 new messages