There's no reason any of those couldn't be in a .gitconfig file.
Prepend the alias with ! it's executed via a shell. I use it to embed shell functions (which generally call git)
Eg an alias to show commits missing (useful when using cherry pick)
show-missing-commits = "!show_missing_commits() { local target=\"${2:-$(git rev-parse --abbrev-ref HEAD)}\"; printf -- 'Showing commits present in \"%s\" but not \"%s\"\n' "$1" "$target"; git log --no-merges \"$1\" ^\"${target}\"; }; show_missing_commits"What I mean is I’d like git to do it natively. But git was written assuming a posix shell and it shows up here and there sadly.
Example:
git command1 —-flag1 <some_separator> command2 —-flag2
Should be possible for git to simply interpret sequentially.Given that the entire point of POSIX is cross platform compatibility, this is one of the few times when I will say they (Linus/git) got it 100% right.
> Should be possible for git to simply interpret sequentially.
Simply? What should it do if the first command fails? Should it exit early? What if you want it to run the second only if the first returns error? What if you want to pipe the first to the second? Or use it as an argument?
Aliases have a "simple" mode where they call exactly one thing. Anything beyond that can't be simple, without also being useless.
If Microsoft can't ship a POSIX compatible shell that's on them, and if you insist on using an OS that doesn't have a POSIX compatible shell, that's on you.
I don't start Linux and ask why it doesn't run whatever people use Windows for... malware I assume?
You’d eventually reinvent a shell. But for just these 2 cases you’d just need 2 separators analogous to the & and && of the shell. But yeah it gets messy if you wanted to run a non git command in the middle.
The thing is, all those !a && b are perfectly valid in both posix and cmd. It just refuses to do the whole “if it starts with ! call the shell”. I guess all that’s missing is that it just needs to execute it. That would probably be the less complicated change. That at least doesn’t seem like a big controversial addition (maybe this is already done now it was a couple of years since I tried and hit a brick wall with aliases under cmd)
Being able to define an && alias in .gitconfig would be great for being able to share snippets like these across shells and OS:es.
My most used alias is by far “git oops” for git commmit —all —-amend —-no-edit