4

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
  • 302,674
  • 57
  • 556
  • 614
Behrooz Karjoo
  • 4,250
  • 10
  • 38
  • 48

1 Answers1

8

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
  • 302,674
  • 57
  • 556
  • 614