tags:

views:

32

answers:

2

this is probably naive question:

i have file config.yml which is in .gitignore file when I'm switching branch to 'someotherbranch' and next i switch back to master

then I don't see config.yml

why ignored files are vanishing after switching branch and what can I do to avoid it?

A: 

if the file exists in the second branch it will be deleted when you switch back.

make sure the file does not exist in 'someotherbranch'

knittl
+1  A: 

Files which are tracked AND ignored are treated like normal files. This usually happens if you ignore the files after you've added them.

Lets say you add a file 'ignored', commit it, then create two branches 'normalbranch' and 'removedbranch'. Then you add a .gitignore with the file ignored in the 'normal' branch and remove the file in the 'ignore' branch.

At this point, if you merge removedbranch into normalbranch git will remove the file 'ignored', regardless the 'ignore' setting. Or to put it short: only git status cares about '.ignored' files.

You could remove the file from all branches with git rm --cached <file> to remove it from git without remove the actual file. After this point everything should work as usual

This is btw. the way to ignore a file which is currently tracked.

Cheers, Reto

reto