git常用命令
# 查看提交历史,找到要回退的commit hash
git log –oneline
恢复到以前的某个版本
git reset –hard 93424a2
# 强制推送,会覆盖远程的提交历史(之前的一些提交)
git push –force origin master
强制拉取远程 覆盖本地
git pull –force origin master
丢弃所有未提交的修改,回到最近一次提交的状态
git reset –hard HEAD
查看分支
git branch
切换分支
git checkout feature-xc
验证结果
git branch
# 查看当前状态
git status
————文件冲突 checkout 文件名 进行覆盖 ——–
# 方法 A:直接 checkout 覆盖(保留文件但内容变回远程版本)
git checkout HEAD — .env
git pull origin master
—————– 如何忽略文件———–
git rm –cached .env
. 确保 .gitignore 已包含 .env
提交本次修改
git add .gitignore
git commit -m “停止监控并忽略 .env文件”
git push origin master