Page 1 of 1

[QUESTION] Help with a git pull script

Posted: Wed Jan 09, 2019 9:08 am
by bobo5290461
Hello,
Happy newyear everyone , good health and much arcolinuxF (Fun).

Because i'm not that strong in scripts but growing here's my question.

I have a directory ArcoLinuxB
Inside that directory I have Xfce and Cinnamon and Budgie and so on
Then in each one i have Max and Min where i put my Githubs
/ArcoinuxB/Xfce/Max
/ArcoliuxB/Xfce/Min
/ArcoLinuxB/Cinnamon/Max
/ArcolinuxB/Cinnamon/Min
and so on for every desktop
Now i have to go in each directory , open a terminal and do a git pull (26 iso's and counting....)

Can someone get me started to make 1 script that does it all in one time?

Re: [QUESTION] Help with a git pull script

Posted: Wed Jan 09, 2019 9:50 am
by erikdubois
This is what I use.

Code: Select all

count=0

count=$[count+1]
tput setaf 1;echo "Github "$count;tput sgr0;
# if there is no folder then make one
[ -d $HOME"/ARCOLINUX/arcolinux-applications" ] || git clone https://github.com/arcolinux/arcolinux-applications
cd arcolinux-applications
git pull
echo "#################################################"
echo "################  "$(basename `pwd`)" done"
echo "#################################################"
cd ..

count=$[count+1]
tput setaf 1;echo "Github "$count;tput sgr0;
# if there is no folder then make one
[ -d $HOME"/ARCOLINUX/arcolinux-arc-themes" ] || git clone https://github.com/arcolinux/arcolinux-arc-themes
cd arcolinux-arc-themes
git pull
echo "#################################################"
echo "################  "$(basename `pwd`)" done"
echo "#################################################"
cd ..

count=$[count+1]
tput setaf 1;echo "Github "$count;tput sgr0;
# if there is no folder then make one
[ -d $HOME"/ARCOLINUX/arcolinux-awesome" ] || git clone https://github.com/arcolinux/arcolinux-awesome.git
cd arcolinux-awesome
git pull
echo "#################################################"
echo "################  "$(basename `pwd`)" done"
echo "#################################################"
cd ..
You can make it smaller with case structures or for loop but this does the job.

With copy/paste and search/replace it can be done very quickly.

Re: [QUESTION] Help with a git pull script

Posted: Wed Jan 09, 2019 9:52 am
by bobo5290461
So after good search, i found this.

Code: Select all

where="/mnt/7796ED7F6111804C/ARCOLINUX GIT/ArcoLinuxB/"

repos=( 
  "${where}/AWESOME/MAX/arco-awesome"
  "${where}/AWESOME/MIN/arco-awesome-minimal"
  "${where}/BSPWM/MAX/arco-bspwm/"
  "${where}/BSPWM/MIN/arco-bspwm-minimal/"
  "${where}/BUDGIE/MAX/arco-budgie"
  "${where}/BUDGIE/MIN/arco-budgie-minimal"
  "${where}CINNAMON/MAX/arco-cinnamon"
)

echo ""
echo "Getting latest for" ${#repos[@]} "repositories using pull --rebase"

for repo in "${repos[@]}"
do
  echo ""
  echo "****** Getting latest for" ${repo} "******"
  cd "${repo}"
  git pull --rebase
  echo "******************************************"
done
And it does the trick. I have no idea if it's proper writen but it works.

Re: [QUESTION] Help with a git pull script

Posted: Wed Jan 09, 2019 9:54 am
by erikdubois
great share

Re: [QUESTION] Help with a git pull script

Posted: Wed Jan 09, 2019 9:55 am
by erikdubois

Code: Select all

git pull --rebase
I would read up on this command.
Do you need it? Do you want?
I do not use it.

Re: [QUESTION] Help with a git pull script

Posted: Wed Jan 09, 2019 10:10 am
by bobo5290461
Indeed, i removed it.

I just a FULL PULL and it works great! So now i can spend more time for the fun stuff!!!!!!!!!!!!!!

Re: [QUESTION] Help with a git pull script

Posted: Wed Jan 09, 2019 11:11 am
by erikdubois
Leave the boring part to the scripts

Re: [QUESTION] Help with a git pull script

Posted: Sat Feb 02, 2019 6:08 pm
by bobo5290461
Little update ,

in .bashrc-personal i made an alias

alias gitpull="find . -maxdepth 3 -name .git -type d | rev | cut -c 6- | rev | xargs -I {} git -C {} pull"

So now in one move i can update all my directories and sub directories !!!
I know, i'm lazy. :evil: :evil: :evil:

Re: [QUESTION] Help with a git pull script

Posted: Sat Feb 02, 2019 7:18 pm
by erikdubois
Yes you are
You can do anything with scripting
you gotta love it
:geek: :ugeek: