我按照这些说明合并 Git 笔记。
我克隆了一个仓库,将笔记引用添加到提交记录中 (refs/notes/commits
)。当我推送时,中央仓库会拒绝它,因为它不是快进式的——因为已经有了该提交对象的 refs/notes/commits。因此为了合并远程笔记引用到我的本地笔记引用中,
$ git checkout refs/notes/master
$ git fetch refs/notes/commits
$ git merge FETCH_HEAD
Auto-merging 206155715a78c9d91d42cda1de98449d2e0b1d36<br>
CONFLICT (add/add): Merge conflict in 206155715a78c9d91d42cda1de98449d........
Automatic merge failed; fix conflicts and then commit the result.
$ vi 206155715a78c9d91d42cda1de98449d........ [fix the conflict as usual manually]
$ git add 206155715a78c9d91d42cda1de98449d........
$ git commit -m "updated Notes"
[detached HEAD 0afb80f] changed notes
$ git update-ref refs/notes/commits HEAD
$ git checkout master <br>
Previous HEAD position was 0afb80f... changed notes
Switched to branch 'master'
$ git push origin refs/notes/commits
success
问题是,这是否是最好的方法?
按照git笔记手册的说明,我尝试了以下操作。
$ git fetch refs/notes/commits
$ git notes merge -v refs/notes/commits
Nothing to Update!
上述步骤显然对我无效。是否有一种方法可以使用git notes merge命令并合并注释,而不是第一幅图所示的“分支方法”?对于我的用途,这个简单直接的命令会更有帮助。
git notes merge
。参考:http://www.kernel.org/pub/software/scm/git/docs/git-notes.html - Vincegit checkout refs/notes/master
,或者至少注意你正在工作的分支。 - Vincegit fetch refs/notes/commits
吗?据我所知,如果没有在前面指定仓库作为其先行参数,你是无法指定 refspec 的。 - Adam Spiers