我在第一次提交时搞错了作者信息。
然而,似乎大多数变基或树修改操作都依赖于其他某个提交已经存在。
即使我运行Git的交互式变基命令,我在我的提交列表中看到的只有一行“noop”。 :/(通过使用
在
以下内容看起来像是一个相关的可能的替代答案,但我认为对于这种特殊情况,需要更多或至少更具体的回答: 从Git分支中删除提交 另一个答案(如何撤消最后一次提交?)导致了以下结果:
对于那些想知道为什么我不直接编辑文件并重新添加到提交中的人,我有错误的作者信息,我在运行“git commit”之后才纠正了它,并且当我打开提交消息进行编辑时更改了作者信息。
也许我可以尝试删除整个.git文件夹之类的东西,但我更喜欢一种更优雅的方式。
此外,如果我不删除整个.git文件夹,我就可以保留我的挂钩和其他东西,我有一种感觉,这种问题的答案将涉及到Git中的基本设计原则,我可能还没有理解。
然而,似乎大多数变基或树修改操作都依赖于其他某个提交已经存在。
即使我运行Git的交互式变基命令,我在我的提交列表中看到的只有一行“noop”。 :/(通过使用
git rebase -i --root
对Git树的root
运行我的变基来解决此问题,但是删除我进行的第一个提交的行并没有实际从树中删除它。)在
root
或第一个提交之上进行变基是不起作用的。[vagrant@localhost vagrant]$ git rebase -i HEAD~1
fatal: Needed a single revision
invalid upstream HEAD~1
[vagrant@localhost vagrant]$ git rebase -i HEAD
Unknown command: rnoop
Please fix this using 'git rebase --edit-todo'.
[vagrant@localhost vagrant]$ git rebase --edit-todo
[vagrant@localhost vagrant]$ git rebase --abort
以下内容看起来像是一个相关的可能的替代答案,但我认为对于这种特殊情况,需要更多或至少更具体的回答: 从Git分支中删除提交 另一个答案(如何撤消最后一次提交?)导致了以下结果:
[vagrant@localhost vagrant]$ git reset --soft HEAD~
fatal: ambiguous argument 'HEAD~': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
[vagrant@localhost vagrant]$ git reset --soft HEAD
对于那些仍在阅读的人,这里是我之前提到的带有noop
的vim缓冲区:
noop
# Rebase 3d1c632..3d1c632 onto 3d1c632 (1 command(s))
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
对于那些想知道为什么我不直接编辑文件并重新添加到提交中的人,我有错误的作者信息,我在运行“git commit”之后才纠正了它,并且当我打开提交消息进行编辑时更改了作者信息。
也许我可以尝试删除整个.git文件夹之类的东西,但我更喜欢一种更优雅的方式。
此外,如果我不删除整个.git文件夹,我就可以保留我的挂钩和其他东西,我有一种感觉,这种问题的答案将涉及到Git中的基本设计原则,我可能还没有理解。
git commit --amend
呢?我很可能误解了你的问题所在。 - castis