How can I not include a file in the commits?

Fran Haselden August 27, 2014

Using SourceTree and BitBucket for a Wordpress project.

Checked in wordpress wp-config.php file which holds the details to the database for the online/staging version of our site.

I want this file to stay in the repository but NOT be checked out with the rest of the files, as it overwrites the local version which has different database credentials.

How can I stop this? Every time I pull, it overwrites my version of the file. I tried "stop tracking" but it wants me to commit this to the main respository, which will obviously affect the file which is checked in.

Users cloning the project should NOT check out the wp-config file with the rest of the files, and it should leave their own in place.

3 answers

1 vote
Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 27, 2014

I would recommend renaming the version that is in the repository to wp-config.default.php, ignore "wp-config.php" and commit the .gitignore file, and instruct users who are cloning the repository for the first time to copy wp-config.default.php to wp-config.php and change values as necessary.

0 votes
Fran Haselden August 27, 2014

I have done, added the following to my own .gitignore file and pushed that file to respository:

*.log

.htaccess

sitemap.xml

sitemap.xml.gz

wp-config.php

wp-content/advanced-cache.php

wp-content/backup-db/

wp-content/backups/

wp-content/blogs.dir/

wp-content/cache/

wp-content/upgrade/

wp-content/uploads/

wp-content/wp-cache-config.php

Still, when I go into Source Tree there in the working copy is my wp-config.php file.

0 votes
Deleted user August 27, 2014

use git ignore to ignore this file on both repositories

Fran Haselden August 27, 2014

I have done, but it is still there waiting to be checked in.

Created .gitignore with following:

*.log

.htaccess

sitemap.xml

sitemap.xml.gz

wp-config.php

wp-content/advanced-cache.php

wp-content/backup-db/

wp-content/backups/

wp-content/blogs.dir/

wp-content/cache/

wp-content/upgrade/

wp-content/uploads/

wp-content/wp-cache-config.php

Checked this in. Still see wp-config as modified file.

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 27, 2014

I don't think you can ignore files that are already tracked.

Fran Haselden August 28, 2014

How can I untrack them? At present I cannot do anything with my entire branch unless I manually untick the wp-config. Is this not a feature that Source Tree can handle? Seems bad to me.

Seth
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2014

I explained the recommended steps in my answer. Comment on that if something is unclear.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events