我在承诺信中写错了。

我怎么能改變訊息呢?承諾尚未推動。


当前回答

如果你只是想编辑最新的承诺,使用:

git commit --amend

git commit --amend -m 'one line message'

但是,如果你想连续编辑多个命令,你应该使用重定向,而不是:

git rebase -i <hash of one commit before the wrong commit>

此分類上一篇

在文件中,如上面的文件中,输入编辑或其他选项之一,然后点击保存和输出。

现在你将处于第一个错误的承诺,在文件中进行更改,它们将自动为你排列。

git commit --amend

保存和输出这个和类型

git rebase --continue

移动到下一个选择,直到完成所有的选择。

请注意,这些事情在这个特殊的承诺之后改变了您的所有SHA<unk>。

其他回答

如果你只是想编辑最新的承诺,使用:

git commit --amend

git commit --amend -m 'one line message'

但是,如果你想连续编辑多个命令,你应该使用重定向,而不是:

git rebase -i <hash of one commit before the wrong commit>

此分類上一篇

在文件中,如上面的文件中,输入编辑或其他选项之一,然后点击保存和输出。

现在你将处于第一个错误的承诺,在文件中进行更改,它们将自动为你排列。

git commit --amend

保存和输出这个和类型

git rebase --continue

移动到下一个选择,直到完成所有的选择。

请注意,这些事情在这个特殊的承诺之后改变了您的所有SHA<unk>。

您也可以使用 git filter-branch 为此。

git filter-branch -f --msg-filter "sed 's/errror/error/'" $flawed_commit..HEAD

它不像一个虚假的吉特承诺 - 修正,但它特别有用,如果你已经有一些合并后你的错误的承诺消息。

请注意,这将试图重新写下头部和错误的承诺之间的每一个承诺,所以你应该非常明智地选择你的msg过滤器命令 ;-)

我添加了 Aliases reci 和 recm for recommit (amend) 它. 现在我可以用 git recm 或 git recm -m:

$ vim ~/.gitconfig

[alias]

    ......
    cm = commit
    reci = commit --amend
    recm = commit --amend
    ......
git commit --amend -m "your new message"

更新您的最后一个错误的承诺消息与新的承诺消息在一个行:

git commit --amend -m "your new commit message"

或者,尝试 Git 重新设置如下:

# You can reset your head to n number of commit
# NOT a good idea for changing last commit message,
# but you can get an idea to split commit into multiple commits
git reset --soft HEAD^

# It will reset you last commit. Now, you
# can re-commit it with new commit message.

使用重新设置将命令分成较小的命令

git 重新设置可以帮助您将一个承诺分成多个承诺:

# Reset your head. I am resetting to last commits:
git reset --soft HEAD^
# (You can reset multiple commit by doing HEAD~2(no. of commits)

# Now, reset your head for splitting it to multiple commits
git reset HEAD

# Add and commit your files separately to make multiple commits: e.g
git add app/
git commit -m "add all files in app directory"

git add config/
git commit -m "add all files in config directory"

在这里,你成功地将最后的承诺分成两项承诺。