我为 git 创建了下面的别名,但它似乎不能在多行中工作,甚至不能在一行中工作,下面是否可能以某种方式工作?
[alias]
reset-dev = "!f() {
current_branch=$(git rev-parse --abbrev-ref HEAD);
echo "Work finished on branch '$current_branch'. Now resetting back to 'develop' and deleting the branch.";
read -p "Do you want to continue? (Yes/No): " choice
case "$choice" in
[Yy]|[Yy][Ee][Ss])
echo "Continuing...";
git checkout develop; # Directly switch to 'develop'
git pull origin develop; # Directly pull from 'develop'
git branch -d $current_branch;
echo "Switched to 'develop' and deleted $current_branch.";
echo "Reset complete.";;
*)
echo "Operation aborted."; exit;;
esac
}; f"
添加自定义子命令的另一种方法:
如果您创建一个名为
git-foo-bar
的脚本,并且可以从 $PATH
访问该脚本,则可以运行 git foo-bar
,就好像 foo-bar
是有效的 git 子命令一样。git-reset-dev
脚本。
要拥有跨多行的别名:在每行末尾添加
\
。