
我正在嘗試設定 git 別名,因為我經常鍵入以下命令:
git commit -m 'update' -- hdf5_classification/output
為了讓別名我正在做:
git config alias.up '! git commit -m 'update' -- hdf5_classification/output'
但是當我嘗試透過鍵入來使用別名時,git up
出現以下錯誤:error: pathspec 'hdf5_classification/output' did not match any file(s) known to git.
答案1
如果 hdf5_classification 位於儲存庫的頂級目錄中,您的命令對我有用。
從 git-config 手冊頁:
Note that shell commands will be executed from the
top-level directory of a repository, which may not necessarily be
the current directory.
我懷疑你想要的命令是:
git config alias.up 'commit -m "update" -- hdf5_classification/output'
它在當前目錄中運行 git commit ,因為它不是 shell 命令(因為它不以“!”開頭)。
附註:您在命令中的單引號內使用單引號,這恰好可以工作,但我認為它並沒有按照您認為的方式進行:-)