Setting your branch to exactly match the remote branch can be done in two steps:
(可以通过两个步骤将分支设置为与远程分支完全匹配:)
git fetch origin
git reset --hard origin/master
If you want to save your current branch's state before doing this (just in case), you can do:
(如果要在执行此操作之前保存当前分支的状态(以防万一),可以执行以下操作:)
git commit -a -m "Saving my work, just in case"
git branch my-saved-work
Now your work is saved on the branch "my-saved-work" in case you decide you want it back (or want to look at it later or diff it against your updated branch).
(现在,您的工作将保存在分支“ my-saved-work”上,以防万一您决定退回该文件(或稍后查看或将其与更新后的分支进行比较)。)
Note that the first example assumes that the remote repo's name is "origin" and that the branch named "master" in the remote repo matches the currently checked-out branch in your local repo.
(请注意,第一个示例假定远程仓库的名称为“ origin”,并且远程仓库中名为“ master”的分支与本地仓库中当前已签出的分支匹配。)
BTW, this situation that you're in looks an awful lot like a common case where a push has been done into the currently checked out branch of a non-bare repository.
(顺便说一句,您遇到的这种情况看起来很糟糕,就像一个普通情况,即已推送到非裸存储库的当前签出分支中。)
Did you recently push into your local repo? (您最近是否进入了本地仓库?)
If not, then no worries -- something else must have caused these files to unexpectedly end up modified. (如果没有,那么就不用担心-某些其他原因一定会导致这些文件意外地被修改。)
Otherwise, you should be aware that it's not recommended to push into a non-bare repository (and not into the currently checked-out branch, in particular). (否则,您应该注意,不建议将其推送到非裸仓库(尤其是不要放入当前已签出的分支)。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…