美文网首页swift
批量git pull小脚本

批量git pull小脚本

作者: 枫山别院 | 来源:发表于2018-12-13 18:22 被阅读0次

欢迎访问我的博客,同步更新: 枫山别院
有时候在某个目录下有很多git工程,每次一个个的git pull非常的不方便,所以写了一个小脚本,每次运行一下就可以了,相当方便,如下

#!/bin/bash

function showMsg()
 {
   echo -e "\033[32m$1\033[0m"
 }

function getdir(){
    for element in `ls $1`
    do  
        dir_or_file=$1"/"$element
        if [ -d $dir_or_file ]
        then
            cd $1"/"$element 
            showMsg 'git pull '$element
            git pull
        else
            echo $dir_or_file
        fi  
    done
}
root_dir="/Users/scott/Documents/code"
getdir $root_dir

只要替换一下root_dir的路径就可以了
将git pull 替换一下,就可以作为另一个脚本使用,比如,替换为 git gc 可以压缩 git 库

相关文章

网友评论

    本文标题:批量git pull小脚本

    本文链接:https://www.haomeiwen.com/subject/pwibhqtx.html