Thane
Thane

Reputation: 382

Why does git ls-files ignore the working directory when used in a git alias?

I have a git repository with a few files and subdirectories. If I have a terminal window open in one of these subdirectories and execute git ls-files, I get a list of the files within my current working directory. If I create the following alias and run it in the same directory:

[alias]
    lsAlias = "!f () { params=($GIT_PREFIX); cd \"${params[0]}\"; /home/user/some-script.sh; }; f"

some-script.sh calls pwd and git ls-files. pwd Correctly reports the current directory as expected, but git ls-files is behaving as if I am calling the command from the root of the git repository. If I adjust the alias to cut out the shell script:

[alias]
    lsAlias = "!f () { params=($GIT_PREFIX); cd \"${params[0]}\"; pwd; git ls-files; }; f"

I get the same behavior.

Here is the transcript of the second alias:

+ f
+ params=($GIT_PREFIX)
+ cd TestApp/Training/
+ pwd
+ git ls-files

This is running in git-bash on Windows 10.

How do I have git ls-files respect the current working directory?

Upvotes: 1

Views: 59

Answers (0)

Related Questions