1

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?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • This seems like a bad idea somehow.. At a guess, it's either a password file or a local database? There's probably a better way. [XY Problem](http://www.perlmonks.org/index.pl?node_id=542341) – Daenyth Sep 29 '10 at 17:36

1 Answers1

1

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
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250