【git】自动备份脚本

Thursday, August 24, 2023
本文共128字
1分钟阅读时长

⚠️本文是作者P3troL1er原创,首发于https://peterliuzhi.top/posts/git%E8%87%AA%E5%8A%A8%E5%A4%87%E4%BB%BD%E8%84%9A%E6%9C%AC/。商业转载请联系作者获得授权,非商业转载请注明出处!

I, too, do not envision a doctrine of self the clinging to which there would not arise sorrow, lamentation, pain, grief, and despair. — The Buddha

以下脚本实现了本地的自动版本管理并提供了一些人性化的log

#!/bin/bash
git add *.py
echo "the following files is added to git:"
ls *.py
if [ -z "$*" ];then
    git commit -m "`date -Iseconds`"
    echo "no specified messege for git commit, automatically using current date as the updating messege"
else
    git commit -m "$*"
    echo "using $* as the messege for updating"
fi
git log --graph --stat -n 3
echo "HELP:"
echo '$ git revert <commit_hash> # recover to a commitment'
echo "DONE."