How to do it...

We have now prepared the setup for pushing and fetching notes. The challenge is that Git is not a default setup for retrieving and pushing notes, and hence you won't usually see other people's notes:

  1. We start by showing that we did not receive the notes during the clone:
$ git log -1 b4f07df357fccdff891df2a4fa5c5bd9e83b4a4a --notes=alsoCherryPick
warning: notes ref refs/notes/alsoCherryPick is invalid
commit b4f07df357fccdff891df2a4fa5c5bd9e83b4a4a
Author: Matthias Sohn <[email protected]>
Date:   Tue Sep 24 09:11:47 2013 +0200
    
    Prepare re-signing pgm's ueberjar to avoid SecurityException
  1. As expected, the output does not show the note, and the first line makes it clear why. In the chapter5 directory, we will see the note. To enable the notes to be fetched, we need to create a new fetch rule configuration; it needs to be similar to the fetch rule for refs/heads. Take a look at the configuration from git config:
$ git config --get remote.origin.fetch
+refs/heads/*:refs/remotes/origin/* 
  1. This shows that we are fetching refs/heads into the refs/remotes/origin reference, but what we also want to do is fetch refs/notes/* into refs/notes/*:
$ git config --add remote.origin.fetch '+refs/notes/*:refs/notes/*'
  1. You should now have it configured. If you leave out the --add option from your command, you will overwrite your current settings. Verify that the rule now exists:
$ git config --get-all  remote.origin.fetch
+refs/heads/*:refs/remotes/origin/*
+refs/notes/*:refs/notes/*
  1. Now, try and fetch the notes:
$ git fetch
From /tmp/chapter5
* [new ref] refs/notes/alsoCherryPick -> refs/notes/alsoCherryPick
* [new ref] refs/notes/commits -> refs/notes/commits
* [new ref] refs/notes/defect -> refs/notes/defect
  1. As the Git output indicates, we have received some new refs. So, let's check whether we have the note on the commit now:
$ git log -1 b4f07df357fccdff891df2a4fa5c5bd9e83b4a4a --notes=alsoCherryPick
commit b4f07df357fccdff891df2a4fa5c5bd9e83b4a4a
Author: Matthias Sohn <[email protected]>
Date:   Tue Sep 24 09:11:47 2013 +0200

    Prepare re-signing pgm's ueberjar to avoid SecurityException
More output...
    Signed-off-by: Matthias Sohn <[email protected]>
Notes (alsoCherryPick):
    570bba5
  1. We now have the notes in our repository, which is what we expected.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.236.174