1

I'm writing a shell script (zsh) that will run git commands for a set of directories. Some of these are projects with .rvmrc files which can take a while to run. When I cd into the directory to run a command, it activates the .rvmrc which really slows down the script quite a bit.

Example command: $(cd $dir && exec git branch)

I would like to either run the commands without cding into the directory in my script, or temporarily deactivate the .rvmrc file so cding into the directory does not run the rvmrc.

Any thoughts?

2
  • Possible duplicate of git pull while not in a git directory Commented Mar 22, 2017 at 18:09
  • The proposed duplicate ('git pull while not in a git directory') seems to cover the same ground as the accepted (only) answer, but it isn't entirely clear how/why that evades the problems with Ruby's version manager (which is what .rmvrc files relate to, it seems). Commented Mar 22, 2017 at 18:59

1 Answer 1

7

you can specify the git working directory and .git location:

git --work-tree=$dir --git-dir=$dir/.git branch
git -C $dir branch

There are also environmental parameter available, please check the manuals

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.