这是我的提交后文件:
#!/bin/sh
unset GIT_INDEX_FILE
git --work-tree=../foo2 --git-dir=/m/Downloads/foo1/.git checkout -f
cd ../foo2/
git add .
git commit -m $1
[在foo1
存储库上进行提交时,我需要将已提交的文件移至foo2
存储库,并使用相同的提交消息来提交这些文件。
“移动文件”步骤工作正常。我现在的问题是获取提交消息。
您可以通过git show
获取提交消息:
git show --no-patch --format=%B
您也可以在提交时使用STDIN作为提交消息:
echo "foo" | git commit --file=-
使用这两位,您应该能够从一个存储库中获取提交消息,并将其用作另一存储库中的提交消息:
git --git-dir=/m/Downloads/foo1/.git show --no-patch --format=%B | git commit --file=-