简体   繁体   English

git - 在变基时排除提交

[英]git - exclude commits when rebasing

I have recently merged a feature that was not ready to go into master.我最近合并了一个尚未准备好进入 master 的功能。 Without realizing it I rebased the bad master into another branch that was good.没有意识到这一点,我将坏的 master 重新定位到另一个好的分支。

But now I am not sure how to pull those bad commits out of my other story.但现在我不知道如何从我的另一个故事中提取那些错误的提交。

HERE is my git log file这是我的 git 日志文件

commit 15bb0d630f9b9cf59axxxxxxx8100d3a7302
Author: Moises Zaragoza <mZaragoza@xxxx.com>
Date:   Mon Jun 1 11:45:31 2015 -0400

    Some updates 


commit 3caf183afe3f5d7dcfxxxxxxxa239d44c8dfd11a
Author: Moises Zaragoza <mZaragoza@xxxx.com>
Date:   Mon Jun 1 11:45:31 2015 -0400

    Some updates 

commit 3c6c81c7a3215fcdxxxxxxxb56a5540745c397
Author: Moises Zaragoza <mZaragoza@xxxx.com>
Date:   Wed Jun 3 16:59:31 2015 -0400

    Bad Commit that should not be here 

if you haven't pushed your code yet, you can do an interactive rebase and delete commits:如果你还没有推送你的代码,你可以做一个交互式 rebase 并删除提交:

git rebase --interactive 3c6c81c7a3215fcdxxxxxxxb56a5540745c397^

You will end up with an editor with commit history:你最终会得到一个带有提交历史的编辑器:

3c6c81c7a3215fcdxxxxxxxb56a5540745c397 Bad Commit that should not be here
3caf183afe3f5d7dcfxxxxxxxa239d44c8dfd11a Some updates 
15bb0d630f9b9cf59axxxxxxx8100d3a7302 Some updates 

If you want to delete commit 3c6c81c7a3215fcdxxxxxxxb56a5540745c397, just delete this line in the interactive rebase and save:如果要删除 commit 3c6c81c7a3215fcdxxxxxxb56a5540745c397,只需在交互式 rebase 中删除此行并保存:

3caf183afe3f5d7dcfxxxxxxxa239d44c8dfd11a Some updates 
15bb0d630f9b9cf59axxxxxxx8100d3a7302 Some updates 

see http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-Historyhttp://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM