Just a quick question, hopefully:

My team maintains a piece of software that uses ClickOnce deployment and is signed with a certificate. We keep the public certificate that is actually used on a separate machine that is only used for signing. That works fine.

Where we occasionally run into issues, though, is when someone has to sign it locally with a new test certificate so they can build and test the solution. Inevitably, this new certificate fingerprint gets pushed up to version control as part of the project settings file. It doesn't cause an issue on the signing box as its own certificate settings are never pushed to the Git server, so pulls from that machine don't override the local changes. However, it does cause issues for everyone else as they have their own test certificate that gets used on their local machine.

Is there a correct way to handle this situation? Maybe some way in Git to exclude changes from just a particular part of a configuration file, rather than the entire thing?

1 Answer 1


There's no way in Git to exclude changes to just part of a file. What you can usually do however is externalise that part of the file to a different config file and then add that other config file to the .gitignore file. That lets each developer customise the config as they require but stops them accidentally checking in their changes and affecting others.

How you do this obviously varies depending on language/framework. As you mention ClickOnce I'm going to assume it's a .Net solution in this case. Let's say you've got a web.config with the following content

  <certificate path="C:\test\whatever.cert">

You can replace this with

<signingInfo configSource="signing.config">

"signing.config" is added to the .gitignore file. Each developer then sets up signing.config as they need locally and there's no need to explicitly remember not to commit changes to it.

  • I really like this idea. It's simple and elegant. Do you know if there's a way to do this when the config data is in project file itself (such as .csproj or .vbproj). I'm googling it currently, however I keep getting results on partial classes, rather than partial config files.
    – Michael
    Jun 18, 2015 at 19:12
  • 1
    I've not tried it personally but you should be able to use an <Import Project=""> element in your main project file and point it to another project file containing your developer specific config. Jun 18, 2015 at 19:19
  • Nice. Four years working with .NET and I never knew that was possible. I'll try it out. Thanks!
    – Michael
    Jun 18, 2015 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.