Skip to content

Instantly share code, notes, and snippets.

@ynezz
Last active April 17, 2025 17:15
Show Gist options
  • Save ynezz/79e29d60f6e55d6b45b0b6f5620c8bdd to your computer and use it in GitHub Desktop.
Save ynezz/79e29d60f6e55d6b45b0b6f5620c8bdd to your computer and use it in GitHub Desktop.
git filter-repo example

commit-callback.py

import sys

original_hex = commit.original_id.decode("utf-8")
new_line = f"(cherry picked from commit {original_hex})\n".encode("utf-8")
commit.message += new_line

feed-mediatek

  • contains complete history for just bunch of OpenWrt components, moving them to the root folder
  • history is cut off to the specified date (so not complete, but should be good enough), which is basically the 24.10 branch off point
git clone \
  --reference ~/dev/openwrt/openwrt.git/ \
  --shallow-since='Thu Oct 31 22:15:37 2024 +0100' \
  --branch openwrt-24.10 \
  --no-tags
  https://github.com/openwrt/openwrt.git

git filter-repo \
  --force \
  --path package/utils/fitblk \
  --path package/system/fstools \
  --path package/network/config/wifi-scripts \
  --path package/network/services/hostapd \
  --path package/network/utils/iw \
  --path package/network/utils/iwinfo \
  --path package/kernel/mac80211 \
  --path package/kernel/mt76 \
  --path target/linux/mediatek \
  --path-rename 'package/utils/':'' \
  --path-rename 'package/system/':'' \
  --path-rename 'package/network/config/':'' \
  --path-rename 'package/network/services/':'' \
  --path-rename 'package/network/utils/':'' \
  --path-rename 'package/kernel/':'' \
  --path-rename 'target/linux/':'' \
  --commit-callback ../commit-callback.py
@Ansuel
Copy link

Ansuel commented Apr 17, 2025

I used

git filter-repo \
  --force \
  --path package/utils/fitblk \
  --path package/system/fstools \
  --path package/network/config/wifi-scripts \
  --path package/network/services/hostapd \
  --path package/network/utils/iw \
  --path package/network/utils/iwinfo \
  --path package/kernel/mac80211 \
  --path package/kernel/mt76 \
  --path target/linux/mediatek \
  --path target/linux/generic/backport-6.6 \
  --path target/linux/generic/pending-6.6 \
  --path target/linux/generic/hack-6.6 \
  --path target/linux/generic/config-6.6 \
  --path target/linux/generic/files \
  --path-rename 'package/utils/':'' \
  --path-rename 'package/system/':'' \
  --path-rename 'package/network/config/':'' \
  --path-rename 'package/network/services/':'' \
  --path-rename 'package/network/utils/':'' \
  --path-rename 'package/kernel/':'' \
  --path-rename 'target/linux/mediatek':'mediatek' \
  --path-rename 'target/linux/generic/':'linux/generic/' \
  --commit-callback ../commit-callback.py

to also handle generic linux kernel patches and files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment