Iowa
Iowa

Reputation: 2491

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?

Upvotes: 80

Views: 20166

Answers (2)

Pratik Ambani
Pratik Ambani

Reputation: 2568

The answer is very well articulated by Simont but just wanted to introduce you to git notes binary.

  1. You can use the below command to add your notes,

git notes add -m "MY_NOTE_MESSAGE" HASH_OF_COMMIT

  1. and push the notes to remote repo using git push

git push origin refs/notes/*

Upvotes: -2

simont
simont

Reputation: 72667

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.

Upvotes: 91

Related Questions