Search code examples
git

Where is the best place to store local-branch-specific metadata in Git?


I'm improving my company's git workflow, and I'm trying to identify the best possible way to store a little bit of per-branch metadata that will stay local to each user's local repository.

Options I've considered:

  • Storing key-value data in git config --local.
  • Storing key-value data as a tag.
  • Storing key-value data in an external json file.

Ideally, I'd like this information to be version controlled, as a safety mechanism, but this isn't strictly necessary.

Are there any options I've missed? Of these options, which is the least problematic?


Solution

  • There is precedent for per-branch config to provide extra information about a branch:

    branch.<name>.description
    Branch description, can be edited with git branch --edit-description.

    https://git-scm.com/docs/git-branch#Documentation/git-branch.txt-branchltnamegtdescription

    It's not key-value, but scripts can serialise and deserialise key-values into this.