Managing Files Through Git That Will Never Be Committed

I have several files on my machine that will always be different from those in our Git repository (the ASP web.config file, which has different settings for my local window from our production servers and the .rds file for report services, in which has my personal credentials to connect to our report server). What do you recommend for working with Git in this scenario?

What I do not want to do is store these files every time I commit. I also do not want to create a branch containing these 2 files, because then on each commit, I must first transfer the main branch, and from there dcommit to the main SVN repo that we use. It would also be nice to ignore these files, as others could make changes to them that I need.

As a final result, I would like to be able to do everything at any time, and not always add everything else to my index, except for these two files.

+4
source share
3 answers

Smudge / clean scripts are a way to handle this. Essentially, when they are checked, the empty connection string is replaced by your dev connection string. When you commit, the connection string is "cleared" by the second script, and the repository has a version with an empty string.

alt text

alt text

Now that you are running diff and there are changes in this file, they will be the only ones that never change.

When deploying, I would not dwell on this. You want to deploy scripts processed by the IT department outside the workflow of your developer.

you can read more about this: https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_keyword_expansion

hope this helps.

+4
source

I am checking a generic configuration file that changes without version, .gitignore -d local config. This seems to be the standard way to do this.

+1
source

Use the .gitignore file and check it in your repository.

http://git-scm.com/docs/gitignore

However, check out the web.config.sample sample, which allows new developers to quickly copy the file as web.config to get started. You might want to write a simple script or README file in the root of the project, which explains to people how to get started with the project. You can also put other custom files that are not important to the project, such as .suo files.

0
source

Source: https://habr.com/ru/post/1336395/


All Articles