git - 在我的 repo/branch 上运行 git reset --hard 确实 --NOT-- 将我带到最后一次提交。怎么修?
问题描述
如上。可能最好用屏幕截图/示例来解释。
这是我的测试分支的最新提交。
以下是控制台命令。
- 如果您参考第一个 git log,分支上的最后一次提交是“42a90f86f992ca3e346597f9f639ef4cb7e3cf19”(应该对应于屏幕截图中的提交)。
- 然后我运行 git reset --hard,这应该让我回到同一个提交,但由于某种原因,它正在重置为一个更旧的提交。
$ git branch * test $ git pull origin test From bitbucket.org:flinderswebtransformation/scholarships-system * branch test -> FETCH_HEAD Already up-to-date. $ git log commit 42a90f86f992ca3e346597f9f639ef4cb7e3cf19 Merge: 6ace73c ef6af98 Author: my-user <my-user@my-host.com> Date: Tue Sep 21 06:37:35 2021 +0000 Merged in dev (pull request #22) changed datasources for dev and test commit ef6af98d28aebd00e2d0a80c775d31c35d243fee Author: my-user <my-user@my-host.com> Date: Tue Sep 21 16:06:46 2021 +0930 changed datasources for dev and test $ git reset --hard origin/test HEAD is now at 4b2c4a3 Merged in bug/SP-1790-remove-references-css-js-and-etc (pull request #17) $ git log commit 4b2c4a36467fd6711e8a7193471c67335b59e14d Merge: a0fd07e 868b500 Author: my-user <my-user@my-host.com> Date: Mon Aug 5 01:00:55 2019 +0000 Merged in bug/SP-1790-remove-references-css-js-and-etc (pull request #17) fixed references to assets and updated links to use AEM ones Approved-by: my-user <my-user@my-host.com> commit 868b5006adea72c1e69ec54266caf13c4870cb5e Author: my-user <my-user@my-host.com> Date: Mon Aug 5 10:15:26 2019 +0930 fixed references to assets and updated links to use AEM ones $
解决方案
git reset --hard HEAD~1
(这也将删除您的最后一次提交和文件)
推荐阅读
- javascript - 使用 JavaScript 创建新的“动画”实例(div 上的 CSS 属性)
- python - 我正在尝试通过 python 打开任何程序文件
- .net - Azure IoTHub 设备不会收到每个孪生更改
- sql - 是否可以在 Postgres 的插入查询中重用单个子查询的标量结果?
- python - Django - 为所有现有用户创建配置文件
- java - 无法使用 java 创建 docker 映像。错误消息是“......:错误处理 tar 文件(退出状态 1):意外 EOF”
- apache-zookeeper - 如何在 Windows 中安装的 Zookeeper 中设置 SSL
- scala - ClassNotFoundException:引起:java.lang.ClassNotFoundException:csv.DefaultSource
- java - 使用弹簧形式时无法从类型 [null] 异常转换
- typescript - 如何在 Visual Studio 2019 中使用具有功能的 .net core + typescript + webpack + npm 模块?