2

I want to write a batch file to run git add, git commit and git push on a bunch of repositories on my machine so I don't have to do it manually every time. Do git commands have a directory path parameter?

Joachim Sauer
  • 291,719
  • 55
  • 540
  • 600
Behrooz Karjoo
  • 4,110
  • 8
  • 35
  • 47

1 Answers1

5

The common option -C specifies the directory you want git to treat as the current directory:

git -C ~/myGit commit -m "great commit message"

is effectively equivalent to

cd ~/myGit ; git commit -m "great commit message"

except that it doesn't actually change the current directory in the current shell.

Joachim Sauer
  • 291,719
  • 55
  • 540
  • 600