Can I version dotfiles within a project without merging their history into the main line?

I'm sure this title is fairly obscure. I'm wondering if there is some way in git to tell it that you want a certain file to use different versions of a file when moving between branches, but to overall be .gitignored from the repository.

Here's my scenario: I've got a Flash Builder project (for a Flex app) that I control with git. Flex apps in Flash Builder projects create three files: .actionScriptProperties, .flexProperties, and .project. These files contain lots of local file system references (source folders, output folders, etc.), so naturally we .gitignore them from our repo.

Today, I wanted to use a new library in my project, so I made a separate git branch called lib, removed the old version of the library and put in the new one. Unfortunately, this Flex library information gets stored in one of those three dot files (not sure which offhand). So when I had to switch back to the first branch (master) earlier, I was getting compile errors because master was now linked to the new library (which basically negated why I made lib in the first place).

So I'm wondering if there's any way for me to continue to .gitignore these files (so my other developers don't get them), but tell git that I want it to use some kind of local "branch version" so I can locally use different versions of the files for different branches.

Answers


TL;DR

Either a file is ignored or it isn't. However, you can commit files to a branch even if they are ignored; you just need to make sure you don't commit them again on the wrong branch.

Options
  1. You might be able to use submodules or subtree merging if you want to maintain revisions under git, but in a separate project.
  2. Use RCS to version a file ignored by Git. Just be careful with git-clean; if you blow away your *,v files, you will lose your RCS revision history.
  3. Keep a branch with nothing but your custom files in it, and periodically merge the ignored files into your working tree
Option 3, In Detail

Ignore your files on the master branch.

git checkout master
cat << EOF >> .gitignore
.actionScriptProperties
.flexProperties
.project
EOF
git add .gitignore
git commit .gitignore

Create an empty branch to hold your configuration files.

git symbolic-ref HEAD refs/heads/flexconfig
rm .git/index 
git clean -fdx
touch .actionScriptProperties .flexProperties .project
git add .
git commit

Merge your ignored files into your master branch, but leave them ignored.

git checkout master
git merge --no-ff flexconfig

If you run git status at this point, it will show a clean working tree but you will actually have your Flex dotfiles in your working tree. Just don't use git add . or similar, as that will override your .gitignore settings.


Need Your Help

how should i reference a php file from an external javascript file

php javascript url filesystems relative-path

So just a general question: if i have a file structure like this where i have an index page in the root folder along with a scripts folder, and in the scripts folder there are two scripts one a JS ...

updating PHP variable in Query string from JS variable

javascript php jquery mysql

I'm trying to check textbox input against a set of words in a certain order from the database to see if they match. If they do, the user's "quest" will be incremented, which will be sent to the