blob: 4ccc3a71082e66e01c54bf55a3839c7d5297bc52 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/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.
#
# If you want to split a single commit during an interactive rebase, use it like this:
# p Commit to split
# x git-split
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" --no-verify
done
|