我欺騙了作者信息。第一次提交。如果它是分支中唯一的提交,我該如何刪除第一個和唯一的提交?
但是,似乎大部分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