Git:忽略版本控制的文件 [英] Git: Ignoring Version-Controlled Files
问题描述
.gitignore文件在忽略一些我们不想控制的文件时非常有用。不幸的是,当文件已经受版本控制时,它不能使用。例如,我的.gitignore(已经添加到git中)文件可能与我的同事想要的文件不同(例如,我想忽略Vim文件)。每当我对这个文件进行更改时,git都会将其显示为修改后的文件。所以我的问题:
- 有什么办法可以忽略某个已经由Git控制的文件的变化吗?!
- 有什么办法可以提交这些更改,但只保留给我自己吗?显然,我不想使用分支,因为我正在某个分支上工作。 >
- Is there any way to ignore changes for a certain file, which is already controlled by Git?!
- Is there any way to commit these changes, but keep it for myself only? Obviously, I don't want to use a branch, because I am working on a certain branch.
如果要排除特定于进程的文件(如Vim临时文件),请编辑(本地)文件 .git / info / exclude
和在那里添加排除模式。此文件专为特定于开发人员的排除而设计,而不是 .gitignore
,该文件专为项目范围的排除项目而设计。
简短的总结是,每个人都应该对添加到 .gitignore
的内容达成一致。对于您不同意的文件,请使用 .git / info / exclude
。
The .gitignore file is very useful in ignoring some of the files that we don't want to control. Unfortunately, it cannot be used when the file is already under version control. For example, my .gitignore (which is already added to git) file might be different than what my coworker wants it to be (e.g. I want to ignore Vim files). Whenever I make changes to this file, git shows it as a modified file. So my questions:
If you want to exclude files that are specific to your process (such as Vim temporary files), edit the (local) file .git/info/exclude
and add your exclusion patterns there. This file is designed for developer-specific exclusions rather than .gitignore
, which is designed for project-wide exclusions.
The short summary is, everybody should agree on what is added to .gitignore
. For files where you don't agree, use .git/info/exclude
.
这篇关于Git:忽略版本控制的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!