在 'git reset --hard' 命令后忽略 2 次提交

Ignoring 2 commits after a 'git reset --hard' command

我是 Git 的初学者。所以这是场景,在一个空文本文件中,我添加了 One 字符串并执行了以下命令:

git init
git add sample.txt
git commit -m "Added One"
git push origin master

接下来,我在下一行添加了Two并执行了以下命令:

git add sample.txt
git commit -m "Added Two"
git push origin master

并最终 Three 使其包含:

One
Two
Three

然后我执行 git reset --hard 'value of the first commit here' 带回包含 One 的文件并添加 Four 使其成为:

One
Four

所以当我执行提交和推送时,出现以下错误:

Updates were rejected because the tip of your current branch is behind its remote counterpart.

如何推送拒绝其他 2 次提交的提交,以便最终文本文件包含:

One
Four

您需要"force push",用您的本地分支强制替换原始分支:

git push -f