git中的分支描述,继续 [英] Branch descriptions in git, continued

查看:189
本文介绍了git中的分支描述,继续的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我在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

然后在你的后面写一个post-commit回购与以下:

 #!/ 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆