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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

25,469 views 26 12
Join discussion

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