Created
July 19, 2012 16:09
-
-
Save tqheel/3144984 to your computer and use it in GitHub Desktop.
Prevent ASP.Net Web.Config From Being Committed By Git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Run this to reverse ignoring of changes to web.config so it gets committed. | |
git update-index --no-assume-unchanged path_to_file/web.config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Run this in GitBash to temporarily ignore changes to web.config so it does not get committed. | |
git update-index --assume-unchanged path_to_file/web.config |
if you reset this setting use;
git update-index --really-refresh
Wow. The Internet is fascinating. I don't even remember writing this or what project I was referring to at the time.
But thanks for the tip @yvzkr!
But thanks for the tip @yvzkr!
haha your welcome.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When working with another developer on the same app and working off of a localhost db, I get tired of having to change my connection string in web.config every time he changes his conn string to match his local environment (Note: the other dev has to follow this practice as well or this approach will not work).
So to avoid that I use these two GitBash scripts to toggle the tracking of web.config. That way I only commit web.config when there are changes to the file other than dev conn string changes.
Now, you will get an error when you do a pull from the repo when the other dev has made substantive changes to the config file, if you are still running in the "ignore mode" set by ignore-config.sh script. However, just run commit-config.sh, tell git to commit your local changes and then do your pull from the repo again. You may get a merge conflict, so work through that as you normally would, commit your changes, then run ignore-config.sh again to stop tracking your config changes going forward.