Reputation: 4631
In my folder ~/git
I have more than 20 folders containing git-repositories.
I could pull the changes for each repository by running
cd folder1
git pull
cd ..
cd folder2
git pull
cd ..
# etc
In bash I could also solve it with a loop:
for f in $(find . -mindepth 1 -maxdepth 1 -type d);
do
cd ${f};
git pull;
cd..;
done
I'm wondering, if there is a more elegant way, e.g. using xargs
or the -exec
of find
.
Upvotes: 1
Views: 74
Reputation: 88583
If no dir starts with a dot.
for f in */; do (cd "$f"; git pull); done
Or put a function in your ~/.bashrc and use a simple git_pull
:
git_pull()
{
oldwd="$PWD"
cd ~/git
for f in */; do (cd "$f"; git pull); done
cd "$oldwd"
}
Upvotes: 3