aniecki
aniecki

Reputation: 21

Git alias referencing commands executed from a subdirectory of a repo

Two git functions defined in .gitconfig (using alias)

create-file = "!f() { for name in \"$@\"; do echo $name>$name.txt; done; }; f"

m-commit = "!f() { for name in \"$@\"; do git create-file $name; done; }; f"

git m-commit a b c

This runs ok from the top-level directory of a git repo.

How to make it to run it from subdirectory, (to create test files in this subdirectory, not in the top)

Thanks for any help.

Upvotes: 1

Views: 144

Answers (1)

chepner
chepner

Reputation: 531055

The name of the top-level directory is output by git rev-parse --show-toplevel.

Upvotes: 1

Related Questions