Search code examples
git

git: how to push messages added by git notes to the central git server?


it seems like there is no proper documentation regarding git notes. I have added some notes to one of the commit using git notes add command. but when i push the commit, and later do a separate clone, i dont see the note message there. Is there a way to push all the note messages added via git notes command?


Solution

  • Push all notes:

    git push <remote> 'refs/notes/*'
    

    Fetch all notes:

    git fetch origin 'refs/notes/*:refs/notes/*'
    

    [[git-scm.org] (archive)]

    A word of warning: do not use git pull in place of git fetch (that is, git pull origin refs/notes/*:refs/notes/* is wrong). The overall details are complex, but the particular reason git pull is wrong here is that you do not want to merge or rebase refs/notes/commits with your current branch.

    Note: The quoting above is important to avoid expansion of the * shell wildcard.