How can I not include a file in the commits?

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

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.

use git ignore to ignore this file on both repositories

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.

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

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.

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

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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

451 views 6 9
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you