I have this git command that I use a lot as an zsh function.
git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)
What I want to achive is create an alias and be able to call it as git upstream
rather than calling just $ upstream
as an zsh function. The closest I did get was this:
[alias]
upstream = "!fn() { git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD) }; fn"
However, my guess is, it does fail at $(...)
due to some parsing error. The error it shows me is this:
> git upstream
fn() { git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD) }; fn: -c: line 1: syntax error: unexpected end of file
Is what I am trying to do through aliases possible? If not, can you direct me to any kind of a source to create git upstream
command?
Turns out I was very close but just missed a semicolon! 🤦♂️
[alias]
upstream = "!f() { git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD); }; f"