$ git commit --amend not altering/saving 提交信息
$ git commit --amend not altering/saving commit message
我最近 $ git add .
对我的一个存储库进行了一些更改,然后是 $ git commit -m'INcorrect commit message'
。
我决定将不正确的提交消息更改为 'Correct commit message' 使用:
$ git commit --amend
我遵循的说明可以在这里找到:https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages
我使用 Atom,所以 Atom 打开时显示“IN正确的提交消息”,我将其更改为 'Correct commit message' 并保存我的更改。
保存更改后的提交消息后,我做了一个 $ git log -1
期望看到 'Correct commit message';但是,我仍然看到“IN正确的提交消息。”
我到底做错了什么?
备注
在此之前,我按照以下说明将 git 编辑器从 Sublime 更改为 Atom:How do I make Git use the editor of my choice for commits?
我基本用过:
$ git config --global core.editor "atom"
和
$ export GIT_EDITOR=atom
我现在意识到我不必两者都做,但我也意识到这可能也没有什么坏处。
有两个 问题为我解决了这个问题。
一个
正如@torek 在他对我的原始 post 的评论中指出的那样,在调用 Atom 块 git 返回时设置 --wait 参数来自 $ git commit --amend
命令。显然,这对于 git 成功捕获更改的提交消息是必要的,而不是在消息被更改之前返回。有道理。
$ git config --global core.editor "atom --wait"
两个
显然,如果我没有显式保存我修改过的提交信息(command + s on mac),它永远不会得救。我必须这样做才能让提交消息识别我更改的提交消息。
乍一看这似乎很明显;但是,如果我更改了我的提交消息并单击关闭 window 按钮('x' at the top-left of the window on mac),会发生一些奇怪的事情...
如果我更改了提交消息,使用关闭 window 按钮 ('x') 关闭 Atom,然后随后执行 $ git log -1
命令,提交消息将显示原始消息未更改的提交消息。 没什么奇怪的。
但是,如果我随后执行另一个 $ git commit --amend
命令,Atom 将打开并显示 更改了先前 $ git commit --amend
命令的提交消息! 如果你问我,这是非常奇怪的行为。不是 git 大师,只能说这并没有为我消除任何困惑。
底线
附加--wait参数($ git config --global core.editor "atom --wait"
),并且显式 在执行 $ git commit --amend
.
时将更改后的提交消息保存在 Atom 中(mac 上的 command + s)
我最近 $ git add .
对我的一个存储库进行了一些更改,然后是 $ git commit -m'INcorrect commit message'
。
我决定将不正确的提交消息更改为 'Correct commit message' 使用:
$ git commit --amend
我遵循的说明可以在这里找到:https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages
我使用 Atom,所以 Atom 打开时显示“IN正确的提交消息”,我将其更改为 'Correct commit message' 并保存我的更改。
保存更改后的提交消息后,我做了一个 $ git log -1
期望看到 'Correct commit message';但是,我仍然看到“IN正确的提交消息。”
我到底做错了什么?
备注
在此之前,我按照以下说明将 git 编辑器从 Sublime 更改为 Atom:How do I make Git use the editor of my choice for commits?
我基本用过:
$ git config --global core.editor "atom"
和
$ export GIT_EDITOR=atom
我现在意识到我不必两者都做,但我也意识到这可能也没有什么坏处。
有两个 问题为我解决了这个问题。
一个
正如@torek 在他对我的原始 post 的评论中指出的那样,在调用 Atom 块 git 返回时设置 --wait 参数来自 $ git commit --amend
命令。显然,这对于 git 成功捕获更改的提交消息是必要的,而不是在消息被更改之前返回。有道理。
$ git config --global core.editor "atom --wait"
两个
显然,如果我没有显式保存我修改过的提交信息(command + s on mac),它永远不会得救。我必须这样做才能让提交消息识别我更改的提交消息。
乍一看这似乎很明显;但是,如果我更改了我的提交消息并单击关闭 window 按钮('x' at the top-left of the window on mac),会发生一些奇怪的事情...
如果我更改了提交消息,使用关闭 window 按钮 ('x') 关闭 Atom,然后随后执行 $ git log -1
命令,提交消息将显示原始消息未更改的提交消息。 没什么奇怪的。
但是,如果我随后执行另一个 $ git commit --amend
命令,Atom 将打开并显示 更改了先前 $ git commit --amend
命令的提交消息! 如果你问我,这是非常奇怪的行为。不是 git 大师,只能说这并没有为我消除任何困惑。
底线
附加--wait参数($ git config --global core.editor "atom --wait"
),并且显式 在执行 $ git commit --amend
.