I created the below alias for git, but it doesn't seem to work in multilines, not even in one line, is the below possible somehow?
[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"
Another way to add custom subcommands:
if you create a script named
git-foo-bar, which is reachable from your$PATH, you may rungit foo-baras iffoo-barwas a valid git subcommand.If your action is not a one liner anymore I would recommend you write it as a separate
git-reset-devscript.To have an alias that spans over several lines: add
\at the end of each line.