zoukankan      html  css  js  c++  java
  • git备份代码

    仓库备份位置: /huawei-bak

    vim /huawei-bak/huawei-bak.sh

    #!/bin/bash
    #项目克隆下来后将其注释即可
    PROJECT="
    git@codehub.devcloud.huaweicloud.com:xxxx.git
    git@codehub.devcloud.huaweicloud.com:xxxx.git
    git@codehub.devcloud.huaweicloud.com:xxxx.git
    git@codehub.devcloud.huaweicloud.com:xxxx.git
    git@codehub.devcloud.huaweicloud.com:xxxx.git
    "
    for i in $PROJECT
    do
      git clone $PROJECT
    done
    #以下为备份代码
    cd /huawei-bak
    ls -l |grep ^d|awk -F ' ' '{print $9}'|grep -v bak$ >> 1.txt
    cat 1.txt | while read Dir
    do
        cd $Dir
        /usr/local/git/bin/git fetch origin      #更新本地的远程分支
        /usr/local/git/bin/git diff --stat master origin/master | grep "changed"    #统计文件的改动,如果有变动则往下执行,反之不执行
        if [ $? -eq 0 ];then
          echo "--------------------------------------------">>../huawei-bak.log
          echo "项目名称: $Dir">>../huawei-bak.log
          echo "同步时间: `date +'%F %T'`">>../huawei-bak.log
          /usr/local/git/bin/git pull >>../huawei-bak.log
          /usr/local/git/bin/git fetch --all      #取远程所有分支到本地(是所有)
        fi
        cd ../
    done
    rm -rf 1.txt

  • 相关阅读:
    leetcode Remove Linked List Elements
    leetcode Word Pattern
    leetcode Isomorphic Strings
    leetcode Valid Parentheses
    leetcode Remove Nth Node From End of List
    leetcode Contains Duplicate II
    leetcode Rectangle Area
    leetcode Length of Last Word
    leetcode Valid Sudoku
    leetcode Reverse Bits
  • 原文地址:https://www.cnblogs.com/smlile-you-me/p/10935747.html
Copyright © 2011-2022 走看看