I'm working on a git alias and have run into syntax issues at its current (incomplete) state:
[alias]
gup2 = !git checkout $1 && BEFORE=$(git stash list) && git stash save gup-temporary-stash && git fetch && git rebase -p origin/$1 && if [ "$BEFORE" != "$(git stash list)" ]; then git stash pop; fi
The problem seems to start when the double quotes are introduced. I've tried many combinations of single quotes and double quotes with escape sequences, but I can't seem to find the right combination.
What is the syntactically correct way to form the above alias?