git 强制使用远程分支的最新代码
没有人富有得可以不要别人的帮助,也没有人穷得不能在某方面给他人帮助。凡真心尝试助人者,没有不帮到自己的。
# 确保当前在目标分支(如 master)
git checkout master
# 获取远程最新状态
git fetch origin
# 强制用远程版本覆盖本地 test.php
git checkout origin/master -- test.php
# 验证文件内容(此时本地文件已被覆盖为远程版本)
cat test.php
# 提交更改(如果需记录强制更新)
git add test.php
git commit -m "强制更新 test.php 为远程最新版本"
# 推送到远程仓库
git push origin master
使用覆盖某个文件

浙公网安备 33010602011771号