我刚刚创建了一个Github存储库,想知道.gitignore文件是干什么用的。我一开始没有创建一个,但添加了一个,因为大多数存储库都有一个。 我需要一个吗?我可以忽略它吗,还是它有用处呢?
当前回答
The .gitignore file is a text file that instructs Git to ignore certain files or folders in a project. A local .gitignore file is normally kept in the project's root directory. You can also create a global .gitignore file, which will be ignored in all of your Git repositories if any entries in it are found. To create a local .gitignore file, create a text file and name it .gitignore (remember to include the . at the beginning). Then edit this file as needed. Each new line should list an additional file or folder that you want Git to ignore.
该文件中的条目也可以遵循匹配模式。
*用作通配符匹配 /用于忽略相对于.gitignore文件的路径名 #用于向.gitignore文件添加注释
其他回答
.gitignore的主要目的-避免添加不相关的文件等。Git
我在某些存储库中有很多个人笔记/涂鸦:它们对我有用,但对其他人没用。我不希望它上传到github,因为它只会让每个阅读它的人感到困惑。好在我可以让git“忽略”这些文件。这种方法的唯一代价是,如果我的电脑死机等,我将无法恢复这些笔记。
The .gitignore file is a text file that instructs Git to ignore certain files or folders in a project. A local .gitignore file is normally kept in the project's root directory. You can also create a global .gitignore file, which will be ignored in all of your Git repositories if any entries in it are found. To create a local .gitignore file, create a text file and name it .gitignore (remember to include the . at the beginning). Then edit this file as needed. Each new line should list an additional file or folder that you want Git to ignore.
该文件中的条目也可以遵循匹配模式。
*用作通配符匹配 /用于忽略相对于.gitignore文件的路径名 #用于向.gitignore文件添加注释
git的ignore file规则允许你忽略过去提交的文件。当您不想重新提交文件时,可以使用它。基本上 它是一个文件列表,你想让git忽略你的工作目录。
它是一个文件列表,你想让git忽略你的工作目录。
假设你在Mac上,所有目录中都有. ds_store文件。你想让git忽略它们,所以你在.gitignore中添加了. ds_store作为一行。等等。
git文档会告诉你所有你需要知道的:http://git-scm.com/docs/gitignore
.gitignore告诉git应该忽略哪些文件(或模式)。它通常用于避免从您的工作目录提交对其他协作者没有用处的临时文件,例如编译产品、ide创建的临时文件等。
你可以在这里找到完整的细节。
推荐文章
- 差异语法突出显示在Github Markdown
- /dist目录在开源项目中的意义是什么?
- Xcode 6 gitignore文件应该包括什么?
- 我如何从现有回购的分支创建一个新的GitHub回购?
- 如何将Git分支移到它自己的存储库中?
- 如何禁用Git凭证管理器的Windows?
- Git 拉取与 Git 变基
- 在git中压缩提交是什么意思?
- 在GIT中合并2个分支
- git标签也会被推送吗?
- 嵌套的Git存储库?
- Git bash错误:无法fork子进程:没有可用的终端(-1)
- 有没有办法在SourceTree中获得两个分支的视觉差异?
- 如何在GitHub上找到存储库项目的创建日期?
- Git标记是否只应用于当前分支?