首页 > 解决方案 > 从历史记录中删除分支

问题描述

我有这种情况:

现在我想Task1从历史记录中删除分支

所做的更改Task1必须保留在Task2

现在是:

开发- Task1 : (commit1, commit2) - Task2 : (commit1, commit2 等)

它应该如下所示:

开发-任务 2:( commit1、commit2、commit3 等)

编辑:

Task1必须删除提交,但所做的更改仍保留在Task2

标签: git

解决方案


分支只是指向提交的指针,所以如果Task2在前面或在同一级别Task1,您可以删除Task1

# delete the branch locally
git branch -d Task1
# delete the branch remotely (if you remote is not called origin, change that with your remote name)
git push origin :Task1

可从中访问的提交Task1仍将位于Task2.


推荐阅读