Debian环境下的文件版本控制实践
一、核心方案与工具选择
二、Git快速上手
sudo apt update && sudo apt install gitgit initgit config --global user.name "Your Name";git config --global user.email "you@example.com"git add .;git commit -m "Initial commit"git log --onelinegit checkout -b feature/x;完成后切回主干并合并:git checkout main && git merge feature/xgit tag -a v1.0.1 -m "Release 1.0.1"git remote add origin <url>;git push -u origin main三、配置文件与系统级管理
sudo apt install etckeepersudo etckeeper init;sudo etckeeper commit "Initial import of /etc"sudo rsync -a --delete /etc /backup/etc-$(date +%F)sudo rsync -a /backup/etc-YYYY-MM-DD/ /etc/四、文件系统快照与回滚
sudo btrfs subvolume snapshot /path/to/configs /path/to/configs-2025-12-11sudo zfs snapshot pool/dataset@2025-12-11sudo zfs rollback pool/dataset@2025-12-11五、误删恢复与风险控制
git checkout <commit-hash> -- path/to/file 恢复到指定提交;git revert <commit> 生成反向提交以撤销更改。