保持git不要求提交更改 [英] Keeping git from requiring commit of changes

查看:122
本文介绍了保持git不要求提交更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在一个3人正在开发的项目中有几个配置文件。但是,这些配置文件包含几行,这些行对我们每个人都不相同,因此不应该被提交更改或覆盖。然而Git不会让我们从其他人那里改变,除非我们提交那些配置文件的改变,这意味着它会改变其他成员的配置。



成为新手Git似乎我们需要创建分支并合并它们,以便每次提交更新我们的代码 - 或者使用.gitignore。处理这种情况的正确方法是什么?我们都需要不断访问其他成员所做的更改。解析方案

跟踪示例配置文件通常是一种好方法。然后你可以有一个未追踪的本地副本。您可以使用 githook 帮助您应用这些差异。您可以将合并后和结账(甚至是提交后)重新复制到未跟踪的跟踪,并可能应用更改以创建您的自定义版本。你最后一步怎么做取决于你 - 这是一个脚本。一些调用 sed -i 可能会这样做。



另一种可能性是,如果你能够使用两个配置文件或配置文件有某种包含指令,应该有一个跟踪和一个未跟踪。


We have several config files in a project that 3 people are working on. However, those config files contain several lines that differ for each of us and so should not be changed or overwritten by commits. Yet Git won't let us pull changes from the other people unless we commit those config file changes which then means that it changes the other members configs again.

Being new to Git it seems that we either need to create branches and merge them every commit to update our code - or use .gitignore. What is the proper way to handle this situation? We all need constant access to the changes that the other members make.

解决方案

Tracking an example config file is generally a good approach. You can then have an untracked local copy. You can use githooks to help you apply the differences. You can have the post-merge and post-checkout (and maybe even post-commit) recopy the tracked to the untracked, and possibly apply changes to create your customized version. How exactly you do the last bit is up to you - it's a script. A few calls to sed -i might do it though.

Another possibility, if you are able to use two config files, or the config files have some sort of "include" directive, is to have one tracked and one untracked.

这篇关于保持git不要求提交更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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