如何删除分支中的合并提交

时间:2014-08-08 16:47:58

标签: git

我需要一些帮助。我需要删除一个提交(在这种情况下,它是我使用--no-ff参数合并到此分支的合并)。正如您在下面看到我的git log,我需要摆脱哈希dc7f605a7ac7af66370ce7cd5e4a1258872325e5这就是这种情况:

commit 56c7a1283518b58cc3c90a84028357f9f4c61c74
Merge: d7bca64 938b607
Author: Luiz Kim Dias <luizkim@gmail.com>
Date:   Wed Aug 6 18:28:52 2014 -0300

    Merge branch 'develop' of bitbucket.org:casperlibero/genet into develop

commit d7bca6495b593af156850db17beb27c0e81f6243
Merge: b3606e2 cc04dc2
Author: Luiz Kim Dias <luizkim@gmail.com>
Date:   Wed Aug 6 18:28:21 2014 -0300

    Merge branch 'integration-204' into develop

commit cc04dc2010db5daa717819503fcbacbc7b4b5425
Merge: 647eec7 0700fd7
Author: Luiz Kim Dias <luizkim@gmail.com>
Date:   Wed Aug 6 18:26:32 2014 -0300

    Merge branch 'task-204' into integration-204

commit 0700fd7e831c33304c72557a489e379af8736842
Author: lkdias <luizkim@gmail.com>
Date:   Wed Aug 6 18:24:06 2014 -0300

    Removendo mais algumas pastas e adicionando um .gitignore para alguns casos

commit 938b60735259f32b2bd5f55c7095d055ebcd6fcc
Merge: 5bc8fd0 1e9bfdb
Author: Édipo Rebouças <edcosta@fcl.com.br>
Date:   Wed Aug 6 16:16:44 2014 -0300

    Merge branch 'integration-178' into develop

commit 1e9bfdb8918b3a70e2ace0ceee4c5e7115d746bd
Merge: b3606e2 041288a
Author: Édipo Rebouças <edcosta@fcl.com.br>
Date:   Wed Aug 6 16:16:13 2014 -0300

    Merge branch 'ecr-card-178' into integration-178

commit 041288a55dd390045cea4da8e778685874c3ae84
Author: Édipo Rebouças <edcosta@fcl.com.br>
Date:   Wed Aug 6 16:15:08 2014 -0300

    correções com chars estranhos

commit e5b7a1f0edf020102abade3f055fe84c50e73bdd
Author: Fábio Garbini <fabio@garbini.net>
Date:   Wed Aug 6 15:44:57 2014 -0300

    Inclusão de botao para copiar link, inclusao de icone da rede social a qual a foto pertence.

commit b6c32dda3e49aff8010d3ea2b43083ba7154ec7f
Author: Édipo Rebouças <edcosta@fcl.com.br>
Date:   Wed Aug 6 14:15:33 2014 -0300

    adicionado campo serviço

// I would like just to get off this hash and left all of other commits safely.
**commit dc7f605a7ac7af66370ce7cd5e4a1258872325e5**
Merge: 0636f68 647eec7
Author: Luiz Kim Dias <luizkim@gmail.com>
Date:   Wed Aug 6 13:28:38 2014 -0300

    Merge branch 'master' into task-204

commit b3606e2e8e960c8aeae3f23f3e1f4492b22de219
Merge: 2a1566e 95b350b
Author: Luiz Kim Dias <luizkim@gmail.com>
Date:   Wed Aug 6 12:27:48 2014 -0300

    Merge branch 'fg-card-172' into develop

commit 647eec7be0b734a741ec8f1b91292c8f13576aaa
Merge: c77ab89 574c8af
Author: Luiz Kim Dias <luizkim@gmail.com>
Date:   Wed Aug 6 11:33:34 2014 -0300

    Merge branch 'release-v1.43.0'

我的问题是:是否可以删除保持所有其他提交安全的特定提交?我说删除这个提交意味着排除我在这个上做的所有机会。

1 个答案:

答案 0 :(得分:0)

尝试git revert HASH,其中HASH是您要删除的提交的哈希值。

基本上,git revert创建一个新的提交,它完全取消了之前的提交。我知道这适用于同一分支中的提交,我认为它在合并提交时可以正常工作。