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?
Asked
Active
Viewed 2,407 times
4

Joachim Sauer
- 302,674
- 57
- 556
- 614

Behrooz Karjoo
- 4,250
- 10
- 38
- 48
-
2Do you mean this? https://stackoverflow.com/a/1386350/10630900 – Minn Dec 02 '19 at 13:45
-
1You could probably also just `cd` into the directories as part of your batch file. – Thilo Dec 02 '19 at 13:46
1 Answers
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