如何删除git notes提交?

如何删除git notes提交?,git,Git,git notes用于添加或检查对象注释。如何删除一个git notescommit,这样git历史中就不存在commit of git notes命令了。我想删除git notes提交,我不是说“git notes remove”,它只删除该注释并进行另一次提交。git notes不会创建自己的提交 它实际上可以用于向现有提交添加(git notes add)一些注释 当您调用git notes remove时,注释将被删除,并且再次不进行自己的提交。由于git将注释存储在一个单独的(孤立的)

git notes
用于添加或检查对象注释。如何删除一个
git notes
commit,这样git历史中就不存在commit of git notes命令了。我想删除git notes提交,我不是说“git notes remove”,它只删除该注释并进行另一次提交。

git notes
不会创建自己的提交

它实际上可以用于向现有提交添加(
git notes add
)一些注释


当您调用
git notes remove
时,注释将被删除,并且再次不进行自己的提交。

由于git将注释存储在一个单独的(孤立的)分支上(默认情况下由
refs/notes/committes
指向),您可以创建分支,指向注释头,像往常一样编辑它(例如使用
rebase
),并更新该分支尖端的注释参考:

// create branch pointing to the tip of notes branch
git checkout -B notes-editing refs/notes/commits

// do whatever you want with notes-editing branch
// for example, git reset --hard HEAD^ to remove last commit

// reset notes reference to the tip of temporary branch
git update-ref refs/notes/commits notes-editing
// remove temporary branch
git checkout master
git branch -D notes-editing

git notes prune
删除不存在/不可访问对象的所有注释。

git notes
不创建自己的提交,但它将显示在历史记录中(
git log--all
)。是否有任何方法可以删除git notes,这样它就不会显示在历史记录中。非常感谢。最后一步:
git branch-D
不会删除
git notes
像往常一样提交分支。是否要完全删除所有notes?然后您应该删除
.git/refs/notes/commits
文件。@max我认为删除
.git/refs/notes/commits
只会删除对注释的(本地)引用,但实际的note对象并非如此。对我来说,唯一有效的解决方案是删除@max指出的
.git/refs/notes/commits
,然后运行
git gc
删除
。如果notes refs已经打包,git/refs/notes/commits
手动操作将不起作用。我必须使用
git update ref-d refs/notes/commits
,然后是
git gc--prune=all--aggressive
。请参考这个答案-