开发者

Tracked files kept secret in a branch

开发者 https://www.devze.com 2023-01-18 15:17 出处:网络
I have a question I can\'t solve out by myself. To put it simply, I\'m wondering if there\'s a way to track a file in a branch while keeping it secret so that it\'s not added into other branches 开发者

I have a question I can't solve out by myself. To put it simply, I'm wondering if there's a way to track a file in a branch while keeping it secret so that it's not added into other branches 开发者_如何学JAVAwhen this branch is merged into another one.

To make it clearer, say you have a branch b1.

Then you add an new file f and you track it (git add f / git commit).

When you merge b1 into another branch b2, the file f is added to the working tree.

I simply would like to avoid this and keep f "private" to b1.

Is there any way to accomplish this?


If you can version a similar .gitattributes in all branches, you could set up a merge driver which would ostensibly ignore the file 'f' content.

So f wouldn't be private on the other branches, but at least it would be empty.
If you need to see its content, you still can ask git to show the f content from the right branch. See for instance "Branch descriptions in git"

git show mySecretBranch:f
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号