git中的分支描述,继续 [英] Branch descriptions in git, continued
问题描述
每当我在git中创建主题分支时,我一直致力于系统保留BRANCH_DESCRIPTION文件。就像其他人提到的那样,我也有时忘记了我创建了一个分支,尽管我试图给它一个描述性名称。
我一直主要关注SO问题我该如何告诉git总是选择我的本地版本来处理特定文件上的冲突合并?,但是我遇到了自定义合并驱动程序未被调用的情况,所以来自正在合并的主题分支中的文件将覆盖本地分支。例如:
git checkout master
echomainline> BRANCH_DESCRIPTION
git add BRANCH_DESCRIPTION
git commit -m'Added BRANCH_DESCRIPTION file'
git checkout -b topic_branch
echo这个分支用于修复[...] > BRANCH_DESCRIPTION
git commit -m'Updated BRANCH_DESCRIPTION'
[code,code,code ...]
[git,git,git ...]
git checkout master
git merge --no-ff topic_branch
此时BRANCH_DESCRIPTION将会被重写,因为主分支的描述没有改变,无论是否为该文件设置了自定义合并驱动程序。
有什么想法?
尝试使用 git notes
来达到此目的。
做 git notes add -m这个分支是为blah blah
#!/ bin / sh
git notes show HEAD〜1
git注意复制HEAD〜1 HEAD
另外添加一个 git notes remove HEAD〜1 如果你想。
使用 git notes show
来查看分支的用途。
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:
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?
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.
这篇关于git中的分支描述,继续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!