【发布时间】:2023-03-16 08:59:01
【问题描述】:
在another question 中建议使用.gitattributes 以保持文件被跟踪但不合并到不同的分支,但我下面的用例似乎不起作用..
mkdir git
cd git
git init
echo "B" > b.txt
git add b.txt
git commit -m 'Initial commit'
echo "b.txt merge=keepMine" > .gitattributes
git add .gitattributes
git config merge.keepMine.name "always keep mine during merge"
git config merge.keepMine.driver "keepMine.sh %O %A %B"
git commit -m 'Ignore b.txt'
git checkout -b test # Create a branch
git checkout master # Back to master and make change
echo "Only in master" > b.txt
git commit -a -m 'In master'
git checkout test
git merge master # The change in b.txt is being merged...
有什么想法吗?谢谢..
【问题讨论】:
-
这看起来像是一种奇怪的愿望,即合并除一个文件之外的所有内容。当所有内容作为一个整体维护时,这违反了 git 意识形态。你能解释一下用例吗?为什么需要它?
标签: git merge branch git-branch branching-and-merging