I’m trying run a git pull on a bunch of folders. This is what I got so far:
find . -type d -name .git \
| xargs -n 1 dirname \
| while read line; do cd $line && git pull; done
Problem is that cd doesn’t work I get a bunch of errors:
sh: cd: ./project_one: No such file or directory
sh: cd: ./project_two: No such file or directory
...
But when I do cd ./project_one it works fine. What’s wrong? Any ideas?
Perform the
cdand subsequent operations in a subshell so that the main process remains in the appropriate directory.