github 本地同步远端配置

timg.jpg
还没更新完~~等待继续优化

git init
git add -A 
git add . 
git commit -m ":tada: Init"
git remote add origin https://用户名:ApiKey@github.com/用户名/项目名.git
git pull -u origin master
git branch --set-upstream-to=origin/master master     github同步至服务器

下面是同步计划任务

#!/bin/bash

source /etc/profile
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
export TERM=${TERM:-dumb}

#----------------------------------------
# Please set the following variable section
# Please set up working directories, use','split
# eg:path="/root/test/path1,/root/test/path2"
path="网站路径"
#----------------------------------------

# Do not edit the following section

# Check if user is root
[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must run this script as root.${CEND}"; exit 1; } 2>&1

# Check if directory path exists
if [[ "${path}" = "" ]]; then 
    echo "${CFAILURE}Error: You must set the correct directory path.Exit.${CEND}" 2>&1
    exit 1
fi

# Check if command git exists
if ! [ -x "$(command -v git)" ]; then
    echo "${CFAILURE}Error: You may not install the git.Exit.${CEND}" 2>&1
    exit 1
fi

# Check where is command git
git_path=`which git`

# Start to deal the set dir
OLD_IFS="$IFS" 
IFS="," 
dir=($path) 
IFS="$OLD_IFS" 

echo "Start to execute this script." 2>&1

for every_dir in ${dir[@]} 
do 
    cd ${every_dir}
    work_dir=`pwd`
    echo "---------------------------------" 2>&1
    echo "Start to deal" ${work_dir} 2>&1
    ${git_path} pull
    echo "---------------------------------" 2>&1
done

echo "All done,thanks for your use." 2>&1
最后修改:2019 年 02 月 24 日 01 : 31 AM
标签:github

1 条评论

  1. gudu

    OωO
    绑定大佬

发表评论