Gitエイリアスが指定したパスを見つけられません

Gitエイリアスが指定したパスを見つけられません

このコマンドを頻繁に入力するため、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 を実行します。

補足: コマンド内で一重引用符の中に一重引用符を使用していますが、これはうまく機能していますが、期待どおりには機能していないと思います :-)

関連情報