Using #Pythonâs #pathlib to compare two repos and get back some missing files from a ârecoveredâ version of a repo (mostly stuff in .gitignore that is handy not to discard right now).
from pathlib import Path
a = Path('sketch-a-day')
b = Path('sketch-a-day_broken')
files_a = {p.relative_to(a) for p in a.rglob('*')
if '.git' not in str(p)
if 'cache' not in str(p)
if 'checkpoint' not in str(p)
}
files_b = {p.relative_to(b) for p in b.rglob('*')
if '.git' not in str(p)
if 'cache' not in str(p)
if 'checkpoint' not in str(p)
}
missing = files_b - files_a
for p in missing:
(b / p).rename((a / p))