首页 > 解决方案 > 如何返回 git master 分支?

问题描述

这是我在 gitlab 上的主分支。我想撤消以前的提交,因为 master 现在不工作。

使用终端,我应该切换到 master 分支,然后:

git revert f23...

在此处输入图像描述

这是获取更多信息的管道,我想回到箭头:

在此处输入图像描述

标签: gitgitlab

解决方案


你可以试试

git reset --soft "HEAD~3"

这将删除您的前 3 个提交。接下来你可以运行:

# remove the staged files
git restore --staged .

# remove the changed files
git checkout -- . 

现在做一些改变并运行:

# add your change
git add .

# commit the change
git commit -m "my change"

# force the push and replace the history
git push -f

推荐阅读