我有時在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