Git alias with positional parameters

前端 未结 7 1064
北荒
北荒 2020-11-22 12:35

Basically I\'m trying to alias:

git files 9fa3

...to execute the command:

git diff --name-status 9fa3^ 9fa3
7条回答
  •  情书的邮戳
    2020-11-22 13:38

    As stated by Drealmer above:

    « Be careful, ! will run at the root of the repository, so using relative paths when calling your alias will not give the results you might expect. – Drealmer Aug 8 '13 at 16:28 »

    GIT_PREFIX being set by git to the subdirectory you're in, you can circumvent this by first changing the directory :

    git config --global alias.ls '!cd "${GIT_PREFIX:-.}"; ls -al'

提交回复
热议问题