我有时在git上使用这个命令。如何在git上添加这个冗长的命令作为别名?
$ git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "[email protected]" ];
then
GIT_AUTHOR_NAME="myname";
GIT_AUTHOR_EMAIL="[email protected]";
git commit-tree "[email protected]";
else
git commit-tree "[email protected]";
fi' HEAD
我想添加,作为别名。 然后我尝试如下,它不工作...
git config --global alias.rewritelog '!f(){ \
git filter-branch --commit-filter \' \
if [ "$GIT_AUTHOR_EMAIL" = "[email protected]" ]; \
then \
GIT_AUTHOR_NAME="myname"; \
GIT_AUTHOR_EMAIL="[email protected]"; \
git commit-tree "[email protected]"; \
else \
git commit-tree "[email protected]"; \
fi\' HEAD \
};f'
此命令后,发生了错误。
zsh: parse error near `then'
为什么不使用shell别名? –
这是解决方案之一。 但我总是直接使用别名的命令。 我在问如何通过git别名来管理它。 – Harry