Last active
April 19, 2018 20:11
-
-
Save yochem/9f752f8dc03334aa7614f339e5b9f62b to your computer and use it in GitHub Desktop.
Pull all your git repo's at once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# 1. Put this file in your $PATH | |
# $ echo $PATH | |
# $ mv gitpull path/to/YOUR_PATH/gitpull | |
# | |
# 2. make it executable | |
# $ cd YOUR_PATH && chmod +x gitpull | |
# | |
# 3. now create a file '.gitrepos.txt' in your home directory | |
# $ touch $HOME/.gitrepos.txt | |
# | |
# 4. go to a repository you want to add and add it to the .gitrepos.txt file | |
# $ cd path/to/repo | |
# $ gitpull --add . | |
# OR from anywhere: | |
# $ gitpull --add path/to/repo | |
# | |
# 5. Pull all repo's at once | |
# $ gitpull | |
reposfile="$HOME/.gitrepos.txt" | |
reset=$(tput sgr0); | |
orange=$(tput setaf 166); | |
bold=$(tput bold); | |
# check if user want to --add a repo (1), | |
# --show the saved repos (2) or just refresh all his/her repos (3) | |
if [[ $1 == "--add" || $1 == "-a" ]]; then #(1) | |
if [[ $2 == "." ]]; then | |
pwd >> ${reposfile}; | |
else | |
echo $2 >> ${reposfile} ; | |
fi | |
elif [[ $1 == "--show" || $1 == "-s" ]]; then #(2) | |
cat $reposfile | |
elif [[ $1 == "" ]]; then #(3) | |
while read -r REPO | |
do | |
(echo -e "${bold}${orange}$REPO${reset}:" && | |
cd ${REPO} && | |
git pull); | |
done < ${reposfile} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment