Skip to content

Instantly share code, notes, and snippets.

@topheman
Created June 29, 2015 17:39
  • Star 36 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save topheman/ec8cde7c54e24a785e52 to your computer and use it in GitHub Desktop.
Git notes cheat sheet

#Git notes

Warning : Support for isplay of git notes has been dropped by github : https://github.com/blog/707-git-notes-display

Resource : https://vimeo.com/34273537

##Add

git notes add
git notes add -m "my note"

##Namespacing

Default namespace is commits

Use git notes --ref COMMAND

Examples:

git notes --ref jenkins add "build pass"
git notes --ref jenkins show HEAD
git log --show-notes=jenkins
git log --show-notes="*"

--show-notes="*" : Quotes are necessary so that * will be passed to git, not evalueted by the command line

##Push

Like tags, notes aren't pushed by default.

git push origin refs/notes/commits
git push origin "refs/notes/*"

##Fetch

Notes aren't fetched by default.

git fetch origin refs/notes/commits:refs/notes/commits
git fetch origin "refs/notes/*:refs/notes/*"

To fetch notes by default : vi .git/config

#edit this part

[remote "origin"]
  fetch = +refs/heads/*:refs/remotes/origin/*

#to become

[remote "origin"]
  fetch = +refs/heads/*:refs/remotes/origin/*
  fetch = +refs/notes/*:refs/notes/*
@Sebi2020
Copy link

This does not work. The notes weren't fetched by this configuration adjustments.

@dten
Copy link

dten commented May 29, 2019

git notes add is missing -m

@mkhoudi
Copy link

mkhoudi commented Jul 27, 2021

Can we push notes by default?

@EBoisseauSierra
Copy link

Can we push notes by default?

@mkhoudi You want to add the following to your ~/.gitconfig or .git/config

[remote "origin"]
  push = +refs/notes/*:refs/notes/*

@CervEdin
Copy link

CervEdin commented Sep 7, 2023

As a command

git config --add remote.origin.fetch '+refs/notes/*:refs/notes/*'
git config --add remote.origin.push '+refs/notes/*:refs/notes/*'

@CervEdin
Copy link

Can we push notes by default?

@mkhoudi You want to add the following to your ~/.gitconfig or .git/config

[remote "origin"]
  push = +refs/notes/*:refs/notes/*

I don't think this is the variant you want, it messes up how git push works by default

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment