From d34161bbda6781a617705ee429776e53768c7b51 Mon Sep 17 00:00:00 2001 From: Anton Bobov Date: Wed, 19 Feb 2020 22:57:02 +0500 Subject: Updates. --- git-split | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 git-split (limited to 'git-split') diff --git a/git-split b/git-split new file mode 100755 index 0000000..6c3398f --- /dev/null +++ b/git-split @@ -0,0 +1,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 -- cgit v1.2.3