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

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

问题描述

如何在SourceTree中编辑不正确的提交消息而不触及命令行?

其他详细信息:




  • 这不是最新的提交。

  • 所有内容都已推送至Bitbucket。

  • 这是一个私有存储库,我是唯一的合作者。

  • 我不介意丢失任何以前的提交,因为我可以随时重新提交。

  • 我不想丢失任何有史以来的代码修改。


    结果:




    • 根据您的评论和回复,目前看起来不可能,我将创建一个新的存储库并开始遍。感谢您的帮助!
    • 之前的使用 SourceTree for Windows 1.5.2.0版的提交(
      不是最近的提交
      ):



      第1步

      选择提交 之前 想要编辑。
      例如,如果我想编辑提交消息FOOBAR!那么我需要
      来选择它之前的提交:



      步骤2



      右键单击所选提交并单击 Rebase children ... interactively



      第3步



      选择要编辑的提交,然后在
      底部单击编辑消息。在这种情况下,我选择提交消息FOOBAR!:


      步骤4



      编辑提交消息,然后单击确定。在我的例子中,我添加了
      SHAZBOT!SKADOOSH!。



      第5步

      当您返回交互式点击 OK 完成
      rebase:





      第6步



      此时,您必须强制推送新的更改,因为您已重新绑定了已推送的
      提交。然而,目前的1.5.2.0版本的
      SourceTree for Windows不允许你通过GUI强行推送,所以
      你需要从命令行使用Git来完成这个任务。



      点击GUI中的终端打开终端。





      步骤7



      使用以下命令从终端强制推送,

        git push origin< branch> -f 

      其中< branch> 是要推送的分支的名称, -f 表示
      来强制推送。强制推送 会覆盖您在
      远程仓库中的提交,但对您的情况无影响,因为您表示您并未共享
      您的与其他人一起回购。


      就是这样!你完成了!


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

      Additional details:

      • This is not the latest commit.
      • Everything was already pushed to Bitbucket.
      • This is a private repository and I am the only collaborator.
      • I don't mind losing any of the previous commits, as I can re-commit them anytime.
      • I don't want however to lose any code modification ever made.

      Outcome:

      • As it seems impossible at the moment according to your comments and replies, I'm going to create a new repository and start all over. Thanks all for your help!

      解决方案

      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:

      Step 1

      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:

      Step 2

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

      Step 3

      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!":

      Step 4

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

      Step 5

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

      Step 6

      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.

      Click Terminal from the GUI to open up a terminal.

      Step 7

      From the terminal force-push with the following command,

      git push origin <branch> -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.

      That's it! You're done!

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

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