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 work simultaneously on several different versions of files with git?
  • Workflow to “backport” change into different Mercurial (Hg) branch?
  • How to only push to one branch in Hg?
  • Moving master head to a branch
  • Cannot open FETCH_HEAD after renaming a branch
  • How to successfully keep master and development branches in sync? 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?

  • Android studio git using private key
  • List Git commits not pushed to the origin yet
  • Can I backup a MongoDB database using Git? Specifically, could I include the mongo data directory in the github repository?
  • NPM install : Git URL dependency error in package.json
  • Ambiguous Names with GIT?
  • How to get count of unpublished commit with GitPython?
  • 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.