0

目前,在我的一个分支中,我有两个提交commit oldcommit latest. commit latest后完成commit old。现在,我只想合并commit latest到主人。我不希望commit old遗嘱做任何改变。如何从 github 中删除特定的选定提交?在阅读了其他答案后,我发现我不能直接从 github 做。我需要先恢复本地分支上的更改,然后再次推送?它让我感到困惑,我如何才能只恢复特定提交的更改并仍然保留我最新提交的更改,如果我这样做了我需要在它之后做什么?

我真的很感激任何帮助或链接。我是 git/github 的新手。

4

2 回答 2

1

您可以通过以下方式推送commit latest(假设 master 本地分支位于commit latest并基于 origin/master):

git checkout -b tmpbranch HEAD~2
git cherry-pick master
git push origin tmpbranch:master

git 最好的功能之一是在最终推动之前有很多方法可以修改本地历史。我刚刚列出的只是一种方式。

于 2013-05-31T03:22:22.120 回答
0

In git if you have a commit - its whole history is part of it. Therefore you cannot merge a single commit, as this implies you merge its whole history, too.

If you do not want the changes of a single commit in the past, the trick is adding another commit on top of the latest one, which is undoing whatever the unwanted commit did. - This can be done with git revert.

There is also git rebase which is very powerful. But please do not use it until you completely understood how git works. - Otherwise you can break things much too easily.

于 2013-05-30T21:13:17.163 回答