在 SourceTree Windows 中编辑提交消息(已推送到远程) [英] Edit a commit message in SourceTree Windows (already pushed to remote)

查看:40
本文介绍了在 SourceTree Windows 中编辑提交消息(已推送到远程)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不接触命令行的情况下在 SourceTree 中编辑不正确的提交消息?

How do I edit an incorrect commit message in SourceTree without touching the command line?

其他详细信息:

  • 这不是最新的提交.
  • 一切都已推送到 Bitbucket.
  • 这是一个私人仓库,我是唯一的合作者.
  • 我不介意丢失之前的任何提交,因为我可以随时重新提交.
  • 然而,我不想丢失任何曾经做过的代码修改.

结果:

  • 根据您的评论和回复,目前似乎不可能,我将创建一个新的存储库并重新开始.感谢大家的帮助!

推荐答案

以下是编辑上一次提交的提交消息的步骤(这是不是最近的提交) 使用 SourceTree for Windows 1.5.2.0 版:

Here are the steps to edit the commit message of a previous commit (which is not the most recent commit) using SourceTree for Windows version 1.5.2.0:

选择紧接在您要编辑的提交之前的提交.例如,如果我想编辑带有消息FOOBAR!"的提交.那我需要选择它之前的提交:

Select the commit immediately before the commit that you want to edit. For example, if I want to edit the commit with message "FOOBAR!" then I need to select the commit that comes right before it:

右键单击选定的提交,然后单击Rebase children...interactively:

Right-click on the selected commit and click Rebase children...interactively:

选择你想编辑的提交,然后点击Edit Message底部.在这种情况下,我选择带有消息FOOBAR!"的提交:

Select the commit that you want to edit, then click Edit Message at the bottom. In this case, I'm selecting the commit with the message "FOOBAR!":

编辑提交消息,然后单击OK.在我的示例中,我添加了SHAZBOT!斯卡多什!"

Edit the commit message, and then click OK. In my example, I've added "SHAZBOT! SKADOOSH!"

当您返回交互式 rebase 窗口时,单击 OK 完成变基:

When you return to interactive rebase window, click on OK to finish the rebase:

此时,您需要强制推送您的新更改,因为您已经重新定位提交你已经推送的.但是,当前的 1.5.2.0 版本Windows 版 SourceTree 不允许您通过 GUI 强制推送,因此无论如何,您都需要从命令行使用 Git 才能做到这一点.

At this point, you'll need to force-push your new changes since you've rebased commits that you've already pushed. However, the current 1.5.2.0 version of SourceTree for Windows does not allow you to force-push through the GUI, so you'll need to use Git from the command line anyways in order to do that.

在 GUI 中单击 Terminal 以打开终端.

Click Terminal from the GUI to open up a terminal.

从终端 force-push 使用以下命令,

From the terminal force-push with the following command,

git push origin <branch> -f

其中是你要推送的分支名称,-f表示强制推动.强制推送将覆盖你对你的提交远程回购,但在你的情况下没关系,因为你说你没有分享您与其他人的回购.

where <branch> is the name of the branch that you want to push, and -f means to force the push. The force push will overwrite your commits on your remote repo, but that's OK in your case since you said that you're not sharing your repo with other people.

就是这样!大功告成!

这篇关于在 SourceTree Windows 中编辑提交消息(已推送到远程)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆