Git 撤消同时处理的分支的合并

Git Undo Merge of Branches that was worked on at same time

我们有一个开发分支和一个我一直在工作的独立功能分支。使用 GitHub 的 UI,我不小心将开发分支(及其所有新提交)合并到功能分支中。

我想清除所有开发分支更改。我考虑过创建一个新分支,然后考虑到这造成的混乱,只是从功能分支中挑选。

这里是 Git 对数图,如果有帮助的话。

| *   14d6767 (origin/feature/) Merge branch 'development' into feature/
| |\
| |/
|/|
* |   2d88b27 Merge remote-tracking branch 'origin/master' into development

你可以:

  • git reset commit_before_merge
  • git checkout commit_before_merge 后跟 git checkout -b feature/this_works,然后,可选地,挑选其他看起来不错的更改