如何在交互式git rebase中选择提交消息

时间:2015-08-06 00:28:25

标签: git

我对在交互式git中重新定位时如何选择提交消息感到困惑。我看到了这条消息:

public void updateUI() {
    if (viewList.size() > 0) {
        ((StackLayout) compositeStacked.getLayout()).topControl = compositeTable;
    } else {
        ((StackLayout) compositeStacked.getLayout()).topControl = compositeNoRows;
    }
    compositeStacked.layout();

    // set input and refresh
    tableViewer.setInput(motorList);
    tableViewer.refresh();
}


public refresh() {
    Job dbJob = new Job("List Retrieve") {
        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                viewList = Databasequery
            } catch (BusinessException e) {
                StatusManager.getManager().handle(
                        new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not retrieve the list", e),
                        StatusManager.LOG | StatusManager.SHOW);
            } catch (Throwable t) {
                logger.warn("Error retrieving list", t);
            }
            return Status.OK_STATUS;
        }
    };

    dbJob.schedule();
}

我只想选择我的第一个提交的现有消息作为此rebase的提交消息,但我对如何实现这一点感到困惑。

1 个答案:

答案 0 :(得分:1)

如果要更改某个Git提交的消息,可以使用交互式rebase并选择reword作为该提交旁边的选项。例如,如果您想要从4次提交之前更改消息,则可以执行此操作:

git rebase -i HEAD~4

pick n3j9sj2 Comment for your most recent commit
pick b9de4la Comment for next most recent commit
pick 78er2nm Comment for an older commit
reword k2nbet3 Here is the commit you want to change

现在,当编辑器屏幕出现时(您在问题中引用),您可以输入所需的任何提交消息。保存并退出时,应更改SHA-1为k2nbet3的提交消息。

请注意,您必须通过以下方式强制将分支推送到远程:

git push --force origin branch_name

执行强制推送可能会对使用分支的其他所有人造成一些问题,因此在执行此操作之前请仔细考虑。

相关问题