覆盖所有未提交的本地文件

Overwrite all local files that are not committed

我对项目做了一些更改并提交了它们。

git pull 在推送之前更新了我的本地分支。

git bash 显示:

The following untracked working tree files would be overwritten by merge:
<list of files>

命令git pull -f具有相同的效果。我不知道该怎么做 git reset --hard origin/<branch_name> 因为据我所知这将 "delete" 我的提交。

如何覆盖所有未提交的本地文件保持提交然后能够推送它们?

您可以将它们的分支重置为您的 当前 HEAD。这样您将删除所有未提交的本地更改,但不会丢失任何提交:

$ git reset HEAD --hard