bash git pull each dir Execute command: git_current_branch () { #https://stackoverflow.com/a/35298459 echo $(git branch | grep '^*' | sed 's/* //' ) } for dir in microservices-* do echo "$dir\n" (cd $dir && git pull origin $(git_current_branch)) echo "\n" done