2011-08-29 43 views
3

我一直在研究一個系統,以便在git中創建主題分支時保留BRANCH_DESCRIPTION文件。和其他人一樣,我也有時忘記了我創建了一個分支,儘管我試圖給它一個描述性的名字。git中的分支描述,繼續

我一直主要關注SO問題How do I tell git to always select my local version for conflicted merges on a specific file?,但我遇到了自定義合併驅動程序未被調用的情況,因此合併的主題分支中的文件將覆蓋本地分支。例如:

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 

此時BRANCH_DESCRIPTION只會被覆蓋,因爲如果自定義合併驅動程序已經設置該文件的主分支的描述並沒有改變無關。

任何想法?

+0

什麼是您存儲在內容中是軌道分支說明什麼道理呢? –

+0

我並不特別強調這個想法。其他SO問題http://stackoverflow.com/questions/2108405/branch-descriptions-in-git讓我走在這個方向,所以我開始檢查出來。我相信你暗指的是,這些信息比應該跟蹤的內容更具元數據? – berto

回答

4

爲此嘗試使用git notes

在你的分支做git notes add -m "this branch is for blah blah"

然後寫在你的回購具有以下提交後:

#!/bin/sh 
git notes show HEAD~1 
git notes copy HEAD~1 HEAD 

另外添加git notes remove HEAD~1如果你想。

使用git notes show來查看分支的用途。

+0

啊,很酷。我不知道git有這個功能,謝謝! – berto

+2

我一直在試驗這個,並注意到使用「git reset」會失去註釋。我猜git reset上的別名可以修復這種情況。 – berto

10

現在的Git運行支持此git branch --edit-description

這個答案有一個nice writeup

+2

雖然描述是本地的。你不能提交它。 – kzh