开发者

Managing files through Git that will never be committed

I have a few files on my machine that will always be different from those that are in our Git repository (an ASP web.config file that has different settings for my local box from our production servers, and a .rds file for reporting services that has my individual credentials in it for connecting to our reporting server). What do you recommend for working with Git in this scenario?

What I don't want to do is stash these files every time I commit. Nor do I want to create a branch that contains these 2 files because then on every commit I have to first commit to the main branch and from there dcommit to the main SVN repo that we use. It also wouldn't be good to ignore these files since others could make changes to them th开发者_开发技巧at I would need.

As a final result, I would like to be able to commit everything at any time instead of always adding everything else to my index except for these 2 files.


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

Managing files through Git that will never be committed

Managing files through Git that will never be committed

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

When deploying, I would not rest on this however. You want deploy scripts that IT Systems department handle and is out of your dev work flow.

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

hope this helps.


I check in the general config file, which is amended with non-versioned, .gitignore-d local config. This seems to be a standard way of doing it.


Use a .gitignore file and check it into your repository.

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜