11 ms·
Git Notes
- galaxyLogic 4y agoIn the WebStorm IDE I can select a (git-) commit and choose "Edit Commit Message". Is that the same thing, or perhaps implemented by using Git Notes?
- jmiserez 4y agoNo that's not the same thing, in fact that'll just do a git rebase, changing the commit itself and all commits after that one. Pretty much the polar opposite of what you want! IntelliJ products try to provide a common interface and common naming for all "VCS" operations, whether it's Git/Mercurial/etc. In practice this obscures the actual Git operations though and requires learning yet another set of "abstract" IntelliJ-specific names for the same thing. I wish they'd stop doing that, it's really confusing and inaccurate.
- galaxyLogic 4y agoWhat they do provide is a menu that says "Edit the commit-message". I don't need to know what commands and command-options to type on the command-line to accomplish that.
- bawolff 4y agoI feel like the biggest problem is they arent fetched by default, so you dont want to put anything important as half the people cloneing your repo wont see them.
- quickthrower2 4y agoAll these bad defaults around notes, and Github not showing them. makes me worry it is defacto deprecated.
- jayd16 4y agoI feel like this is a good default if the idea is to cram in automation metadata.
- makeitdouble 4y agoYou're right, but then the name becomes misleading (it should be "Git Metadata" or something similar) The best way out of this situation could be aliasing the feature to something else with better defaults, with a hope that gets adopted by github/gitlab and the major GUIs
- jayd16 4y agoMaybe just give notes a namespace if it doesn't have it already. That way you can subscribe to some and not others.
- loeg 4y agoYou have your users add remote.origin.fetch='+refs/notes/*:refs/notes/*' to their git config and then they're fetched going forward, but yeah it's annoying that it isn't the default for a fresh clone.
- lrvick 4y agoI experimented with using git-notes to do m-of-n multisig for git: https://github.com/hashbang/git-signatures https://github.com/hashbang/git-signatures
- diarrhea 4y agoWow, I’m kind of the ‘go-to git person’ in my team but have never heard of git notes. An obscure feature.
- ddevault 4y agogit has a lot of stuff, even the experienced can find something new. Have you heard of git bisect yet?
- eropple 4y agoIs git bisect a power user feature? I was taught git by a senior engineer early in my career and it was the first "this will save your rear" tool he showed me.
- SimonPStevens 4y agoI think it depends a lot on the type of project. If you are working on a web app that you can bisect and retest each new version in a few seconds it's an amazing tool. If you are working on a stack of huge server apps with 1h+ build times, and complicated start up procedures you aren't going to find besect very useful at all.
- MartinodF 4y agoI've read many times about git bisect being used effectively on the Linux kernel, so I'm not sure build times are that much of an issue...
- sillysaurusx 4y agoSpeaking of git’s plumbing, https://news.ycombinator.com/item?id=33566991 https://news.ycombinator.com/item?id=33566991 is the best guide I’ve found. It made everything simple. I didn’t realize git is just a list of blobs and trees, and that’s it. And when other people said that, I didn’t understand the meaning. Blobs = any file, keyed by sha1. Also commits (pointer to a tree). Also trees (list of blobs). Refs (aka branch): points to a specific commit. I bet notes are just a blob that points to a commit.
- bombcar 4y agoIt's way too easy to get caught up in how the data is de-duped on disk, but git is much more like a giant pile of zip files that you might think.
- metadat 4y agoThis earned a resubmitted: https://news.ycombinator.com/item?id=33767014 https://news.ycombinator.com/item?id=33767014
- masklinn 4y ago> I bet notes are just a blob that points to a commit. That would make them unusable, as you’d have to read all the notes to know if a commit has one. The notes message is a blob, but the note itself is a tree entry (the name of the entry is the commit being pointed to / annotated).
- reilly3000 4y agoI've seen implementations of gitops CD pipelines use git notes as a store for release metadata and to facilitate image promotion. I like that in theory but I worry about the fact that git notes are mutable.
- aidos 4y agoI’d never heard of these before but that was the usecase that immediately sprung to mind. Seems super useful and the mutability probably isn’t an issue if you’re just plugging in a little internal metadata that’s almost temporary anyway.
- hakre 4y agomy current way to do this is to have build as numbered references of their original commit, and then one on top that contains the build protocol. and thinking: part of the matter from code review outcomes, also some automated check systems have limits, so mutability may be less an issue as first anticipated. git notes might be lightweight enough to not introduce too much bureaucracy.
- amelius 4y agoHow are git notes better than just storing one or more .txt files in a repo?
- m12k 4y agoAccording to TFA, you can add git notes to a commit afterward
- amelius 4y agoTrue, but you can also add a .txt file and refer to the commit from the text.
- emmelaich 4y agoThey can be made after the fact without affecting existing commit sha1s.
- quickthrower2 4y agoThis also makes them presumably not source controlled in the same way? I.e. is it the equivalent of a shared text file of SHA->Text mappings?
- civopsec 4y agoThey are versioned and the log of their changes can be seen by using `git log` on the notes namespace inside `ref/`.
- kryptiskt 4y agoYou can attach them to a commit after the commit has been created, for example the code review example from the article. If you store that data in a commit at HEAD it will not be available in other branches that contain the commit.
- hakre 4y agoYou can see it in the log and only at the relevant commit. No need to git show the object id of the .txt files in the repo to see the message.
- deleted 4y ago[deleted]
- almog 4y agoAs mentioned in the post, git notes can be used for code review, and I wish code review systems would have but a front end system that end up being encoded into the source control itself: think about all the times you had to find the first commit that introduced a specific line then trace it back to the code review that approved that change. It can surely be streamlined even when external to git, but since it's coupled, to me it makes sense that it should reside together and be available offline just like every commit.
- wffurr 4y agoIsn't that what git-appraise is, from the post?
- almog 4y agoRight, git-appraise seems to take that approach (I say "seems" only because I've never used it) yet it's the exception to the rule when compared to almost any other code review system for git that's out there. I'm sure there are good reasons for that being the exception but I'm also guessing that one reason being vendor lock-in.
- pokstad 4y agoI think Gerrit does this with their Note DB: https://gerrit-documentation.storage.googleapis.com/Documentation/2.14.14/dev-note-db.html https://gerrit-documentation.storage.googleapis.com/Document...
- mfontani 4y agoI've tried to use git notes over the years but unfortunately notes are tied to a specific commit hash. It's a blessing and a curse. Works great for some types of review system, or for "tagging" things related to deploy. Notes on commits on the master/main branch, which doesn't get rebased? Awesome thing, they work. But you can't as easily use them on branches: the moment a branch whose commits had notes is rebased, and SHAs change, good-bye notes associated with the "previous" SHAs :/
- l0b0 4y agoDo you need to `git config notes.rewriteRef refs/notes/commits`[1]? [1] https://stackoverflow.com/a/14601464/96588 https://stackoverflow.com/a/14601464/96588
- metafunctor 4y agoI had no idea this even existed, and I've run into this problem with notes myself! This seems like something that should be a default.
- hypothesis 4y agoSeems like a standard git thing: have a process that works in a specific, but not a “helpful” way and also have a undiscoverable setting to configure said process. Is that why people keep building UIs and wrappers for git?
- TylerE 4y agoHaving lots of config is fine, even good, if you ship sane defaults. Frankly most OSS flunks this, and git is one of the biggest offenders.
- rjh29 4y agoGit has so many users that changing defaults is pretty tricky. They have done it in the past but usually over multiple release cycles with a deprecation window.
- smartmic 4y agoThank god there is Fossil [1] for the source code management (yes, management implies also making notes and documentation besides versioning) of my personal projects. [1]: https://fossil-scm.org/ https://fossil-scm.org/
- samwillis 4y agoOther than SQLite, what other large projects (both closed and open source) are using Fossil? It seems to me to fix so many of the usability issues with Git, and is much more opinionated. I much prefer opinionated tools and frameworks, the fewer (unnecessary and trivial) decisions I have to make in life the better.
- smartmic 4y agoTcl/Tk are also some of the larger projects. But I guess the bulk are smaller and personal projects.
- nerdponx 4y agoFossil seems like it would be really useful for long-running internal projects at a company. But the problem is that you need to force people to learn Fossil instead of Git, and companies (perhaps rightly) don't want to pay people to fumble around with an unfamiliar system.
- LukeShu 4y agoLibreCMC used to use Fossil, until they got fed up with people complaining that it wasn't Git.
- gpanders 4y agoWhere do you host your fossil repos (or do you not centrally host them at all)?
- smartmic 4y agoI am self-hosting on a fairly cheap VPS. It is also possible to mirror on Github. And there is chiselapp.com
- synergy20 4y agoin the end the author states "So, for now: git notes are relegated to obscurity. Forever hamstrung by an obscure and clunky interface and limited adoption—I often forget they’re there.", so after the read, I should forgot about it? git does need a 'git bug' to track bugs though, as https://github.com/MichaelMure/git-bug https://github.com/MichaelMure/git-bug does, but I prefer to have it built in git directly if possible.
- makapuf 4y agoWhy not a issues/ directory with one file per issue ? Put comments there, track them by author as commit author. Consider them part of a branch or a release. (So a big could be fixed in a branch and not in another).
- michaelmure 4y agoIt's significantly more friction for little benefit compared to git-bug's solution. First, storing this data alongside the code means requiring everyone agreeing to use that tool (quite high ask). Then, that means that you let git merge said data in case of conflict, which leaves you two options: merge failure, or requiring the user to fix things. None of that is acceptable, and it's why many of previous attempt failed.
- makapuf 4y agoThanks for the reply, interesting. Regarding everyone agreeing, isn't someone quite obliged to use the project approach to bugtracking? If there are bridges, then you could implement them for this also. Re: merging, if you merge some branch that corrects or detects some bug, you have to correct bug definition anyway ? So I'd think its better to merge it explicitly? Not saying it should be good, but I'm tempted to try it to see if it can work.
- michaelmure 4y agoA bugtracker being "branch aware" and able to say where an issue started, where it was fixed ... can (and should IMHO) be a different concern than how the data is stored and how conflict resolution happen. By conflict resolution here, I mean: what happens when two user on different machines edit their issues and then states get merged? If you have this data into some format (let say JSON) and rely on git automatically merging, you eventually end up with corrupted formatting. Instead, you can do all that in your own branches, not pollute the normal code and not let git do any merging. Then, you can still have your bugtracker understand branches and track that information.
- bartvk 4y agoIt seems like these notes aren't supported by the GUI tools (Sourcetree, Fork, etc) nor by web tools like Bitbucket, and even most commandline people don't know about them... that's quite interesting, you could use them for ASCII art, jokes, and basically silliness. And perhaps in the far future, somebody finds those notes. I'm going to run the ticket number through figlet, then put it in a note for each commit.
- cesarb 4y agoBack when the Apache OpenOffice project was still alive, the LibreOffice project used git notes to track, for each commit to Apache OpenOffice, whether it was ignored (usually for being specific to the obsolete openoffice.org build system), redundant with a libreoffice commit (usually because the LibreOffice project had already fixed the same issue in a better way several years before), or cherry-picked into the libreoffice tree (this was the rarest case; in these last two cases, it also pointed to the relevant libreoffice commit); an aoo commit without git notes meant it had not been looked at yet. While the LibreOffice project stopped doing that a couple of years ago (probably because there was no longer anything interesting happening in the aoo repository), you can still see the branch they used to mirror the Apache OpenOffice tree, still with the git notes, at https://git.libreoffice.org/core/+/refs/heads/aoo/trunk https://git.libreoffice.org/core/+/refs/heads/aoo/trunk (follow the parent links to see more, or clone the repository locally and look at that branch with gitk, which also shows the git notes).
- hakre 4y agoThat's a great addition, thanks. I've missed more practical examples in the original article.
- LukeShu 4y agoSame with libav pulling commits from ffmpeg (or was it vice-versa?).
- asalahli 4y agoYeah it was the other way around. As I remember it, libav devs were pretty hostile towards ffmpeg and refused to pull anything from it while the ffmpeg maintainer kept cherry-picking from libav for a long time after the fork. IMO it's probably the primary reason why libav is practically dead now.
- alkonaut 4y agoCould this be used instead of tags as a CI build marker? Using automated tagging of every CI build quickly adds up to thousands of tags polluting tag lists and making git slower.
- tjoff 4y agoI assume you'd loose the ability to work with them as tags though? git checkout v0123 git difftool v0123 v0158 are quite useful. Didn't know it had a performance impact.
- alkonaut 4y agoGood point. Might still be worth it though. When fetching all tags it becomes ridiculous after just a few thousand builds.
- aerovistae 4y agoI had never heard of this feature before but I'm having a hard time seeing why it's useful. It doesn't seem to add anything substantial beyond what a commit message already allows.
- dorian-graph 4y agoI feel like you may have missed a salient section in the blog post. Here's one sentence from that section: > Once a commit cements itself in git’s history—that’s it. It’s impossible to amend a commit message buried deep in a repo’s log.
- erik_seaberg 4y agoIt’s rarely seen but possible to https://git-scm.com/docs/git-replace https://git-scm.com/docs/git-replace a commit and keep its SHA.
- pyrolistical 4y agoWhat if we just reimplemented the entire github ui but everything is just stored in git? Git notes allows comments to be attached to any line for PR. Issues can just be a well known branch and schema. Issue comments are just git notes. Ditto for wiki, project management and releases
- shagie 4y agoDo you really want JRandomUser to be able to add notes to your repository? What additional permisioning and hooks would you need to set up and maintain to allow JRandomUser to be able to add a note to a commit but not create a new commit? ... but they need to be able to create commits on well known branches in order to add issues. Can they make it so that mirrors run out of disk space by adding notes to all the commits or extremely large issues? Should people who have the ability to force push be able to rewrite the contents of anything anyone wrote as an issue or note? This way leads to madness. I'm sure it would be possible... but these are not headaches that I want to have.
- nerdponx 4y agoBut it would be pretty nice if people with commit access could add notes directly to commits in Github.
- account42 4y ago> Do you really want JRandomUser to be able to add notes to your repository? Not any less than I want them to comment via the web interface. > Can they make it so that mirrors run out of disk space by adding notes to all the commits or extremely large issues? Better to solve that than to just not mirror the comments which is what is currently the case. You can always opt your mirror to not fetch notes if that is what you want to do.
- hprotagonist 4y agoIt's called Fossil: https://fossil-scm.org https://fossil-scm.org
- 20after4 4y ago
- blondin 4y agozero added value. let me be the opposing voice. this is a pure nerd add-on with zero value for regular users. i went through all the usage examples. even those from this thread. there is zero added value. you can link, point, store, etc. to your commit and get the same thing.
- michaelmure 4y agogit-bug's author here with my 2cts. For what it's worth, I was aware of git notes during my original design process, but I found them clunky. I realized they would not be enough on their own to do conflict resolution and I'd be better making my own data structure with regular blobs, trees and commits. But when you have that, there is pretty much no point in using notes, as that would just grow the required features on which you sit on. What if I want to port git-bug to mercurial or whatever comes next? Even metadatas (the natural point of notes) are better expressed within that same unique data structure. Additionally, you then only need to sign those commits to cryptographically lock everything.
- civopsec 4y agoI use this to store my own notes on published commits. Mostly about tests that I have done. For private commits I might just store them in the commit message if they are ephemeral. And then remove them before pushing. The usability is okay for local work. Fiddly for pushing and pulling.
- graypegg 4y agoGit seems to do a lot I don’t know of. It was only last year that someone showed me git bisect, and it’s probably saved me at least a full day of stress and commit-shuffling in that time. Git either has some pretty horrible discoverability UX problems, or I just don’t question a tool I use daily. Either way, maybe it’s time I looked at git’s man page
- deleted 4y ago[deleted]
- kazinator 4y agoIf you cherry-pick a commit, does that include its notes?
- Lio 4y agoNot by default. A cherry-pick is like a one commit rebase. You're affectively rewriting the commit's changes somewhere else and so get a new SHA to reflect the new location. Since git notes are tied to a particular SHA they don't get included. You can configure git to do it though. As mentioned else where in the comments, here's a good stackoverflow answer explaining how: https://stackoverflow.com/questions/14585613/is-there-a-way-to-automatically-merge-notes-if-commits-for-those-notes-get-squas/14601464#14601464 https://stackoverflow.com/questions/14585613/is-there-a-way-...
- geokon 4y ago"they’re cool for appending notes from automated systems (like ticket or build systems) but not really for having interactive conversations with other developers" After reading the whole thing I was still not really clear why they not great for conversations with other developers. You could probably even make some automated system that sync'd GitHub commit comments with the repo git notes. You'd just have to settle on a fixed format. .
- deleted 4y ago[deleted]
- T3RMINATED 4y ago
- luispauloml 4y agoI have a question totally unrelated to the post, but that I finally decided to ask because of it. In the tweet by Simon Willson at the top of the blog post, he uses the word "against": Started experimenting with "git notes" against a new repo [...] English is not my native tongue, but I always take the use of this preposition as if to state an adversarial relationship between two things, a relationship of opposition between them. Therefore, sometimes I find it odd the way it is used in programming-related context. A few examples of what I mean: - "to program against a standard" instead of "to program based on a standard" - "to match against a pattern" instead of "to match the pattern onto the thing" - "to compare against a list" instead of "to compare with items from a list" - "to file an issue against the repository" instead of "file an issue at the repository" It is possible (and very likely) that my proposed meanings are grammatically or even semantically wrong, but I feel that "against" is being correctly used in these examples because I can see a slight opposition between the two things in them, and I can understand that some people might even find an adversarial relationship there. However, in the specific case of Simon Willson's tweet, the use of "against" sounds even more off because I fail to see a repository and Git notes as being adversaries or opposite to each other. So the question is: is only me, as non-native speaker, that finds this usage (not only Willson's, but the examples too) a bit weird, or do native speaker also have similar sentiments?
- Someone 4y agoNot a native speaker, but “Against” has many meanings, not all implying adversity/competition. https://www.merriam-webster.com/dictionary/against https://www.merriam-webster.com/dictionary/against mentions, for example, “compared or contrasted with”, which covers the search and compare examples you gave.
- adamweaver 4y agoAgainst has a rare meaning of “adjacency”. We say that we lean something against another, for example. English is weird.
- bacon_waffle 4y agoI'm a native English speaker and agree that it is a slightly weird corner of the language - thanks for asking! "Against" can also mean something like "adjacent to" or "in contact with", like "let's put the chair against this wall".
- revskill 4y agoWhy need git notes when we already have git commit ? Seems redundant for me.
- stokastik 4y agoA common use of git notes is tacking metadata onto commits. Once a commit cements itself in git’s history—that’s it. It’s impossible to amend a commit message buried deep in a repo’s log1. But git notes enable you to amend new information about old commits in a special namespace. And they’re capable of so much more. The article has an answer to this in the second paragraph.
- abinmn 4y agoA lot of comments are mentioning using git-notes with CI/CD systems. Could someone elaborate on how this is done? Like what kind of metadata could be stored. And if there are some references, it would be really helpful.