Branch descriptions in git, continued

I’ve been working on a system to keep a BRANCH_DESCRIPTION file whenever I create a topic branch in git. Like others have mentioned, I too sometimes forget what I created a branch for, even though I try to give it a descriptive name.

I have been primarily working off the SO question How do I tell git to always select my local version for conflicted merges on a specific file?, but I’ve run into a case where the custom merge driver does not get called, so the file from the topic branch being merged in overwrites the local branch. For example:

  • How to merge bug fix branch into trunk and release branch
  • Merging non-git folder with git folder
  • How can I move commits from the trunk to a branch in Git?
  • Use TortoiseSVN to merge branch changes with the trunk
  • Merging branch to multiple branches in Git
  • Coder collaboration best practices using Git
  • git checkout master
    echo "mainline" > BRANCH_DESCRIPTION
    git commit -m'Added BRANCH_DESCRIPTION file'
    git checkout -b topic_branch
    echo "this branch is used to fix the bug where [...]" > BRANCH_DESCRIPTION
    git commit -m'Updated BRANCH_DESCRIPTION'
    [code, code, code ...]
    [git, git, git ...]
    git checkout master
    git merge --no-ff topic_branch

    At this point BRANCH_DESCRIPTION will simply be overwritten since the master branch’s description has not changed regardless if a custom merge driver has been setup for the file.

    Any ideas?

  • How to set up p4merge as diff tool for Visual Studio 2015 | git
  • Create a new branch in Gitlab
  • Doxygen and git for automated file version information
  • Git-log is it possible to ignore removals?
  • Git rebasing branches
  • Hosting a Git repository on an AWS Windows Server
  • 2 Solutions collect form web for “Branch descriptions in git, continued”

    Try using git notes for this purpose.

    In your branch do git notes add -m "this branch is for blah blah"

    Then write a post-commit in your repo with the following:

    git notes show HEAD~1
    git notes copy HEAD~1 HEAD

    Additionally add a git notes remove HEAD~1 if you want.

    Use git notes show to see what the branch is for.

    Git now supports this by running git branch --edit-description

    This answer has a nice writeup

    Git Baby is a git and github fan, let's start git clone.