如何使Git忽略我对文件所做的更改(在源代码管理下)? [英] How to make Git ignore changes I'm making to a file (under source control)?

查看:68
本文介绍了如何使Git忽略我对文件所做的更改(在源代码管理下)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将git用于大型Web应用程序.在我的本地端,我想在git的工作流程中使几个文件保持不变.例如,与实时服务器相比,数据库和配置文件的内容有所不同.我不想让任何git命令覆盖文件.如何锁定或忽略配置文件和数据库文件

I am using git for big web application. At my local end I want to make few files unchanged during work flow of git. For example there is database and config files which have different content as compare to live server. I don't want to let files over written by any of git command. how I can lock or ignore config and database files

推荐答案

使用 .gitignore 文件.此类文件(如数据库配置或具有更改文件的文件夹)不应包含在git存储库中.

Use the .gitignore file for this. Such files like database configurations or folders with changing files should not be included in the git repository.

在大多数情况下,您可以创建一个模板文件,例如

In most cases you can create a template file like

database_config.txt_template

并在您的git repo中提交该文件.当新用户安装该项目时,他可以重命名文件并可以更改设置.

and commit that file in your git repo. When a new user install that project he can rename the file and can change the settings.

这篇关于如何使Git忽略我对文件所做的更改(在源代码管理下)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆