If I type the following into Terminal I can accomplish everything I want:
git commit -am "my commit message" ; git pull ; git push ; ssh user@server 'cd /path/to/git/repo/ ; git pull ; exit'
I'd like to create the same as an alias in my ~/.zshrc
. Something like:
alias pushit () { git commit -am "$@" ; git pull ; git push ; ssh user@server 'cd /path/to/git/repo/ ; git pull ; exit' }
To be run in Terminal like so:
pushit "my commit message"
Instead every time I reload ~/.zshrc (source ~/.zshrc
) or open a new Terminal window I see it loop through my alias dozens of times. It's not clear it actually runs.
What am I doing wrong?
Notes:
~/.zshrc
).You want a function rather than an alias:
function pushit () {
git commit -am "$@"
git pull
git push
ssh user@server -- 'cd /path/to/git/repo/ ; git pull'
}