我欺骗了作者信息。第一次提交。如果它是分支中唯一的提交,我该如何删除第一个和唯一的提交?
但是,似乎大部分rebase或树的修改操作都依赖于其他一些已经存在的commit。
即使我运行Git的交互式rebase命令,我在我的小提交列表中看到的只有一行,“noop”。 :/(运行我对底垫解决了这个混帐树的root
与git rebase -i --root
,但删除行的第一次提交我做实际上并没有从树中删除它。)
衍合上root
顶部或第一提交,不起作用。
[[email protected] vagrant]$ git rebase -i HEAD~1
fatal: Needed a single revision
invalid upstream HEAD~1
[[email protected] vagrant]$ git rebase -i HEAD
Unknown command: rnoop
Please fix this using 'git rebase --edit-todo'.
[[email protected] vagrant]$ git rebase --edit-todo
[[email protected] vagrant]$ git rebase --abort
下看起来像一个相关的可能的备选答案,但我想更多的东西,或者至少更具体的,是值得为这个特殊情况下的答案:
Delete commits from a branch in Git
这对方的回答(How do you undo the last commit?)得到如下:
[[email protected] 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>...]'
[[email protected] vagrant]$ git reset --soft HEAD
在这里,对于那些仍然在阅读本,是VIM缓冲与noop
我前面提到的:
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