I am trying to create an alias that uses both multiple Git commands and positional parameters. There are Stackoverflow pages for each, and it would appear painfully obvious to do both, but I am having trouble.
As an example, I want to switch to branch foo and perform a status. So in my .gitconfig
, I have:
[alias]
chs = !sh -c 'git checkout $0 && git status'
which doesn't work. Whereas something like this will work.
chs = !sh -c 'git checkout $0'
echoes = !sh -c 'echo hi && echo bye'
Any insight would be appreciated.
This will work (tested with zsh and bash):
[alias] chs = !git checkout $1 && git status