首页 > 解决方案 > 在我的 repo/branch 上运行 git reset --hard 确实 --NOT-- 将我带到最后一次提交。怎么修?

问题描述

如上。可能最好用屏幕截图/示例来解释。


这是我的测试分支的最新提交。

在此处输入图像描述

以下是控制台命令。

$ 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

解决方案


git reset --hard HEAD~1(这也将删除您的最后一次提交和文件)


推荐阅读