by nu11p01n73R · 9y ago · 0 comments
Is the exec really required?
git config --global alias.git '!git'
Will also work. Am I missing something?EDIT: From git doc, "If the alias expansion is prefixed with an exclamation point, it will be treated as a shell command"
So exec is not required then.
Also, I found one caveat from the same docs:
> Note that shell commands will be executed from the top-level directory of a repository, which may not necessarily be the current directory. GIT_PREFIX is set as returned by running git rev-parse --show-prefix from the original current directory.
So, if I have a modified file `bar` in subdirectory `foo` under project root, and I am currently in `foo`, git status will show:
modified: bar
but git git status will show: modified: foo/bar
To fix this, we should use cd first: git config --global alias.git '!cd "$GIT_PREFIX" && git'