blob: 6c3398f4f25059d91668b8d03922ae59fc799e99 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#!/usr/bin/env bash
# https://stackoverflow.com/questions/40698651/how-to-split-every-commit-by-file
# Split HEAD commit into multiples with single file in it.
set -e
SHA=$(git rev-parse --short HEAD)
git reset HEAD^
git diff-tree --no-commit-id --name-only -r $SHA | while read -r f; do
git add "$f"
GIT_EDITOR="echo '0a\n$SHA $f\n\n.\nw' | ed -s" git commit -c $SHA
done
|