Skip to content

Instantly share code, notes, and snippets.

@pisceanfoot
Created August 24, 2017 03:52
Show Gist options
  • Save pisceanfoot/84fc93417ccb56b1bbced66c4a69a182 to your computer and use it in GitHub Desktop.
Save pisceanfoot/84fc93417ccb56b1bbced66c4a69a182 to your computer and use it in GitHub Desktop.
pull all git repository from specific path
#!/bin/sh
code_path='/home/**/code_search'
git_pull() {
git_dir_name=$1
echo `pwd`/"$git_dir_name is a git repository."
git -C `echo` `pwd`/$git_dir_name remote | grep -n "origin"
if test $? = 0 ;then
echo "Begin to pull from origin:"
echo `date`
git -C `echo` `pwd`/$git_dir_name pull origin develop
echo "\n"
else
echo "There is no remote repository."
echo "\n"
fi
}
for dir1 in `ls -F $code_path | grep /$`
do
echo 'dir ' $dir1
if [ -d "$dir1/.git" ];then
git_pull $dir1
fi
done
echo "All of the repositories have been updated."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment