How to Retrieve notes from the remote repository (Git)

we need another clone from the local clone we already have. This is to show the push and fetch mechanism of Git with git notes.

Step 1 : Start by checking out the master branch:

Step 2 : Now, create a local branch of all the stable-3.1 branches:

Step 3 : We are checking out all these branches because we want to clone this repository and, by default, all the refs/heads/* branches will be cloned. So, when we clone the jgit directory, you will see that we only get the branches we see if you execute git branch:

Step 4 : Now, go one directory up so that you can create your new clone from the jgit directory:

Step 5 : Now, enter the shareNotes directory and run git branch -a to see that the only remote branches we have are the branches we checked out as local branches in the jgit directory. After this, we are ready to fetch some notes:

Step 6 : We start by showing that we did not receive the notes during the clone:

Step 7 : As expected, the output does not show the note, and the first line makes it clear why. In the jgit 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:

Step 8 : 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/*

Step 9 : 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:

Step 10 : Now, try and fetch the notes:

Step 11 : As the Git output indicates, we have received some new refs. So, let's check whether we have the note on the commit now: