git_自动同步_sync.sh

时间:2023-12-29 16:58:08

1: 使用方法  sh sync.sh  code_dir

代码

#add
echo $1
cd $1
git add .
git commit -m "Added notes for $(date)"
git push -u origin master #delete
git status |grep deleted |awk -F '\t' '{print $2}' |awk '{print $2}' |xargs git rm
git commit -m "delted $(date) $?"
git push
#push to github

2:

添加定时任务  每30s触发一次

crontab -e
* * * * * sleep 30;  /bin/sh /home/iknow/cphmvp/code/sync.sh /home/iknow/cphmvp/code/spider_data_core/  >/dev/null 2>&1