Quick Tips

Running Commands In the Root of a Git Directory

August 15, 2019

I work in monorepos a lot, and often finding myself needing to run commands at the root of a git repoistory from inside a package folder inside the repository. From the root, I use Lerna to run commands in each of the sub-packages, but when I’m cdd into the subdirectory , I just learned I could do something like:

git config --global alias.exec '!exec '

Now I can run things like:

git exec npm run deploy

from within a subdirectory. This is because git aliases always run within the repo root.