Pergunta

I have a git project that I'm working on locally. It's a PHP project with a config file that stores MySQL database connection information. My local MySQL settings are different from the remote settings.

On my remote, I have a post-receive hook that will checkout the files to a folder on the server:

#!/bin/sh
GIT_WORK_TREE="../demo" git checkout -f
chmod +x hooks/post-receive

How can I tell this checkout not to include (overwrite the config file), since it will replace the remote config file with my local one? I've tried adding my local config file to the .gitignore, but that didn't seem to do it.

Any idea how to exclude the config file from the checkout?

Foi útil?

Solução

The proper solution is not committing your config.php (or whatever its name is) at all but rather putting it in the .gitignore and committing config.php.example instead.

So, simply remove the config file from the repository, rename it on your remote machine, pull so you have the newest commit (which would remove the file) and then move it back.

Outras dicas

You can try this

Running command:

git rm -r --cached .

This removes everything from the index, then just run:

git add .

Commit it:

git commit -m ".gitignore is now working"
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top