Skip to content

Instantly share code, notes, and snippets.

@marhensa
Last active August 28, 2023 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marhensa/7a1587252665fc9368ea086ac5fed058 to your computer and use it in GitHub Desktop.
Save marhensa/7a1587252665fc9368ea086ac5fed058 to your computer and use it in GitHub Desktop.
Bash Linux - git pull for all directories (update all repository folders)
ls -R -d */.git | cut -d'.' -f1 | xargs -P10 -I{} git -C {} pull
# make sure to run it on the folder that have all those repositories that needs to be updated
@marhensa
Copy link
Author

marhensa commented Aug 28, 2023

to make an alias, so it could be run in a single simple command: gitpullall

if grep -q "alias gitpullall" ~/.bashrc; then
    sed -i '/alias gitpullall/d' ~/.bashrc
fi

cat <<EOF >> ~/.bashrc
alias gitpullall='ls -R -d */.git | cut -d'.' -f1 | xargs -P10 -I{} git -C {} pull'
EOF

source ~/.bashrc

clear && echo "Now 'gitpullall' is a command to update all repositories folder."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment