I have a database configuration file that has default values that are unimportant. However, any changes to this file would contain sensitive information that should not be t
As usual github has a great doc on this.
https://help.github.com/articles/ignoring-files#ignoring-versioned-files
Here's the relevant snippet:
Ignoring versioned files
Some files in a repository change often but are rarely committed. Usually, these are various local configuration files that are edited, but should never be committed upstream. Git lets you ignore those files by assuming they are unchanged.
- In Terminal, navigate to the location of your Git repository.
- Run the following command in your terminal:
git update-index --assume-unchanged path/to/file.txt
Once you mark a file like this, Git completely ignores any changes on it. It will never show up when running
git status
orgit diff
, nor will it ever be committed.To make Git track the file again, simply run:
git update-index --no-assume-unchanged path/to/file.txt
.
Not sure if this is the "best" way... but what I have found to work takes a few steps.
New Laravel Example:
git init
.gitignore
files for desired results like not losing the vendors folders.git add .
git commit -m "first commit"
git rm --cached public /.htaccess
then git rm --cached .env
git commit
git status
should show those files as deleted.Now those can be edited, and you can have local and production versions. NOTE: You may have to repeat all these steps the first time on the production set-up as well. So far this has worked well for me.