tags:

views:

27

answers:

1

Hello everybody.

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 when 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?

A: 

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
VonC