我在承诺信中写错了。
我怎么能改變訊息呢?承諾尚未推動。
我在承诺信中写错了。
我怎么能改變訊息呢?承諾尚未推動。
当前回答
更新您的最后一个错误的承诺消息与新的承诺消息在一个行:
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"
在这里,你成功地将最后的承诺分成两项承诺。
其他回答
正如前面提到的那样, git commit --amend 是重写最后一份重写的方式。
git commit -a --amend -m "My new commit message"
要改變以前的承諾,做你想要的變化,並進行這些變化,然後執行
git commit --amend
这将打开一个文件在你的文本编辑器代表你的新的承诺消息. 它开始与文本从你的旧承诺消息。 改变承诺消息,如你想要,然后保存文件,然后停止你的编辑器完成。
要更改以前的承诺,并保持相同的日志消息,运行
git commit --amend -C HEAD
修复以前的承诺,通过完全删除它,运行
git reset --hard HEAD^
如果你想编辑多个承诺消息,运行
git rebase -i HEAD~commit_count
此命令启动您的编辑器. 标记第一个命令(您想要更改的命令)为“编辑”而不是“选择”,然后保存和输出您的编辑器。
git commit --amend
git rebase --continue
注意: 您也可以从 git commit 打开的编辑器“做您想要的更改” - 更改
使用
git commit --amend
要详细理解,一个很好的帖子是 4. 重新写 Git 历史. 它也谈论什么时候不使用 git commit --amend。
更新您的最后一个错误的承诺消息与新的承诺消息在一个行:
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"
在这里,你成功地将最后的承诺分成两项承诺。
您可以使用 Git 重定向. 例如,如果您想要修改回来承诺 bbc643cd,运行
$ git rebase bbc643cd^ --interactive
在默认编辑器中,修改“选择”到“编辑”的行,您想要修改的承诺。
$ git add <filepattern>
现在你可以使用
$ git commit --amend
要改變承諾,然後
$ git rebase --continue
要回到前任首席执行官。