主题
Git 使用
运行环境:Windows(Git for Windows / git-bash),命令同样适用于 Linux 的 git。
查历史与回退
bash
git log # 显示从最近到最远的提交日志
git log --pretty=oneline # 只显示提交的 commit id 和对应的注释
git reset --hard commit_id # 彻底将工作区、暂存区和版本库记录恢复到指定的版本
git gc --prune=now # 清理优化本地版本库reset --hard 会丢弃工作区未提交的改动,回退前先确认没有想要保留的内容。
换行符设置
bash
git config --global core.autocrlf false # 提交检出均不转换
git config --global core.safecrlf false # 允许提交包含混合换行符的文件--global 会影响本机全部仓库,只在需要跨平台一致换行的机器上这样设。 core.autocrlf 常见取值:true(提交转 LF、检出转 CRLF)、input(只提交转 LF)、false(不转换)。
验证当前值:
bash
git config --global --get core.autocrlf
git config --global --get core.safecrlf本仓库的注意事项:不做全局换行符转换,避免无关文件被整篇改写。