sh 按文件拆分提交

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 按文件拆分提交相关的知识,希望对你有一定的参考价值。

 git rebase --interactive --exec ./split.sh HEAD~1 # HEAD~1 can be replace by any commit number, this will split by commit + by file in this case
#!/bin/bash

set -e

LF=$'\n'
SHA=$(git rev-parse --short HEAD)
MSG=$(git show -s --format=%B HEAD)
set -f; IFS=$'\n'
FILES=($(git diff-tree --no-commit-id --name-only -r HEAD))
set +f; unset IFS

git reset HEAD^

for f in "${FILES[@]}"; do
  git add "$f"
  git commit -m "$SHA $f$LF$LF$MSG" --no-verify
done

以上是关于sh 按文件拆分提交的主要内容,如果未能解决你的问题,请参考以下文章