Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete git-notes commit?

Tags:

git

git-notes is used to add or inspect object notes. How can I delete a git-notes commit, so the commit of git-notes command will not exist in git history. I want to delete git-notes commit, I'm not mean the "git-notes remove", which only remove that notes and make another commit.

like image 255
Fei Avatar asked Aug 06 '12 13:08

Fei


2 Answers

As git stores notes on a separate (orphaned) branch (pointed by refs/notes/commits by default), you can create branch, pointing at notes head, edit it as usual (using rebase, for example), and update notes reference to the tip of that branch:

// 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
like image 133
max Avatar answered Oct 19 '22 01:10

max


git notes prune Removes all notes for non-existing/unreachable objects.

like image 25
Tim Avatar answered Oct 19 '22 00:10

Tim