git:忽略*版本控制的文件

编程入门 行业动态 更新时间:2024-10-13 04:27:03
本文介绍了git:忽略*版本控制的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 .gitignore 文件允许忽略控制它们的版本文件。

我们有一个不同的情况:我们希望在存储库中放置一些配置文件,这些配置文件需要在每台机器上进行更改(例如db访问信息)。

我们希望分发它们作为占位符,因此我们将它们包含到存储库中。 但是,后来我们希望对所有开发人员的更改予以忽略。

有没有办法做到这一点?

注意:

Git:忽略版本控制文件实际上是相同的。然而,没有一个答案回答了这个问题,包括被接受的答案。

编辑:

  • 是否有办法对模式而不是单个文件执行--assume-不变?
  • 有没有办法传播这个命令到其他开发者的仓库?

解决方案

在我的 .gitconfig file:

[别名] 忽略= update-index --assume - 不变 unignore = update-index --no-assume-unchanged

这应该是你想要的:运行 git ignore some-file 会将文件视为不变,直到您运行 git unignore some-file code>。

A .gitignore file allows to ignore files from version controlling them at all.

We have a different situation: we want to place in the repository some configuration files, that need to be changed on per-machine basis (db access info for instance).

We do want to distribute them, as placeholders, so we include them into the repository. However, later we want any changes to them to be ignored, for all developers.

Is there a way to do it?

Note:

The question Git: Ignoring Version-Controlled Files is actually the same. However, none of the answers answered the question, including the accepted one.

Edit:

  • Is there a way to do --assume-unchanged to a pattern rather than a single file?
  • Is there a way to propagate this command to the repositories of other developers?

解决方案

I define the following aliases in my .gitconfig file:

[alias] ignore = update-index --assume-unchanged unignore = update-index --no-assume-unchanged

That should do exactly what you want: running git ignore some-file will treat the file as unchanged no matter what you do to it, until you run git unignore some-file.

更多推荐

git:忽略*版本控制的文件

本文发布于:2023-10-31 10:50:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1545865.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:版本   文件   git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!