开发者

Branch descriptions in git, continued

开发者 https://www.devze.com 2023-03-31 15:50 出处:网络
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 t

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 开发者_Go百科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:

git checkout master
echo "mainline" > BRANCH_DESCRIPTION
git add 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?


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

This answer has a nice writeup


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:

#!/bin/sh
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.

0

精彩评论

暂无评论...
验证码 换一张
取 消