且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我怎样才能跳过提交git?

更新时间:2022-10-15 16:59:17

我可以给你两个选择:


  • Interactive rebase git rebase -i )为您提供提交列表,编辑该列表将改变操作的结果;允许您重新排序,删除或标记这些提交用于其他操作。在你的情况下,你可以将 [*] 的分支转换为 [_] 的并且删除不需要的行提交。

  • Cherrypick 允许您将单个提交的更改应用到另一个分支。就你而言,你可以简单地将 [*] 提交给 [_] 的分支。


I have some commits that I don't want in my project, but there's a commit based on them which I do want in it. This is my GitHub "Network" graph of the repository (ASCII, as I still cannot post images):

[]--[]--[_]
|        |
|        ------->|
---------->[·]--[·]--[*]

(-> means a merge)

I want to delete the changes made in the two [·] commits, and base the [*] one on the [_] one above. I've tryed merging and rebasing, but they apply the changes of the unwanted commits. Is it possible?

Sorry if I'm not clear, English isn't my mother language. Thanks in advance.

I can give you two options:

  • Interactive rebase (git rebase -i) presents you a list of commits, editing this list will change the result of the operation; lets you reorder, delete or tag these commits for miscellaneous operations. In your case, you can rebase [*]'s branch into [_]'s and delete the lines unwanted commits.

  • Cherrypick lets you apply the changes of a single commit into another branch. In your case, you can simply cherrypick commit [*] into [_]'s branch.