I've different repository and want to keep all of them up to date. A solution can be cd folder; git pull origin master
for all repositories. What I'm looking for is a way to do the same but without cd
each times.
Asked
Active
Viewed 315 times
0

Md. Fazlul Hoque
- 15,806
- 5
- 12
- 32

sensorario
- 20,262
- 30
- 97
- 159
-
5Does this answer your question? [git pull while not in a git directory](https://stackoverflow.com/questions/5083224/git-pull-while-not-in-a-git-directory) – Prav Jul 30 '21 at 22:09
1 Answers
3
Yes, you can have Git change into a directory automatically when it runs by passing the -C
option, like so: git -C DIR pull
.
Note that the -C
option is a general Git option and not one to git pull
, so it must be placed before pull
and not after.
If you have a set of directories under the current directory, you can script this like so:
$ find . -mindepth 1 -maxdepth 1 -type d | xargs -I{} git -C {} pull

bk2204
- 64,793
- 6
- 84
- 100
-
I actually have done the exact same thing, but specifically looking for ".git" directories (then performing operations in their parent directory) and doing "remote update" instead of "pull". I've named it "fgru" and now have been using for years to update my repositories. :-) – Obsidian Jul 30 '21 at 22:16
-