gitignore只是不起作用。我无法理解它.DS_Store& .gitignore文件 [英] gitignore just doesn't work. I can't get it to ignore .DS_Store & .gitignore files

查看:117
本文介绍了gitignore只是不起作用。我无法理解它.DS_Store& .gitignore文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 .gitignore d .DS_Store .gitignore 文件。但是仍然可以在git status中看到它们。



有人可以向我解释如何确保我试图忽略的文件不显示而检查状态?

  git状态

#未记录文件:
#(使用 git add< file> ...包含在将要提交的内容中)

#.DS_Store
#.gitignore

我的存储库的所有子文件夹中都有 .DS_Store 文件。所以我希望所有这些都被忽略。我应该怎么做?



我已经在我的存储库的根目录中配置了 .gitignore 文件。
我是否应该将其复制到所有子文件夹以便git忽略这些文件?
.gitignore 文件中添加 .gitignore 不可接受?



编辑:2014年1月21日==================



我仍然无法确定这一点。
下面的评论并没有真正帮助我。所以我重新发布我的查询。



以下是我的 git status 输出的片段。实际输出跨越几页。这个输出中的所有文件都是我不想在我的回购库中找到的文件/文件夹。这些是未跟踪的文件,所以我从来没有 git add 编辑它们。但是,当我创建一个新项目时,我必须在添加它们之前在这个庞大的列表中搜索相关的文件/文件夹,这会让整个过程变得有点刺激。



<$

$(使用git add< file> ...来包含在提交的内容中)

# ../../.DS_Store
#../../Classes/
#../.DS_Store
#../Basics/.DS_Store
#.. /adt/.metadata/
#../adt/Fundamentals/.classpath
#../adt/Fundamentals/.project
#../adt/Fundamentals/.settings/
#../adt/Fundamentals/bin/
#.DS_Store
#.metadata /

以下是我的 .gitignore 文件。有人可以指出我的错误吗?

  *。class 
* .pyc
colors
** /。DS_Store

#Java移动工具(J2ME)
.mtj.tmp /

#包文件#
* .jar
* .war
* .ear

#Eclipse文件
.project

#文件夹
.classpath /
.settings /
.metadata /
WEB-INF / lib /
META-INF /
服务器/

#字节编译/优化/ DLL文件
__pycache __ /
* .py [cod]

#C扩展名
* .so

#分销/包装
bin /
build /
开发鸡蛋/
dist /
鸡蛋/
lib /
lib64 /
parts /


解决方案


  1. 您不应该忽略您的 .gitignore 。如果您的存储库中没有它,我认为忽略功能不起作用。即使您将它们添加到 .gitignore ,也不会忽略已被跟踪的文件。 。如果您希望在将它们添加到存储库后将它们忽略,则必须先使用 git rm filename 第一个将它们除去。


I have .gitignored .DS_Store and .gitignore files. But still see them in the "git status".

Can someone explain to me how I can make sure that the files that I am trying to ignore don't show up while checking status?

git status

# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   .DS_Store
#   .gitignore

I have the .DS_Store file in all the subfolders of my repository. So I want all of those to be ignored. What should I do?

I have configured .gitignore file in the root directory of my repository. Should I copy this to all the subfolders for git to ignore these files? Is adding .gitignore in .gitignore file not acceptable?

EDIT: Jan 21st 2014 ==================

I still can't figure this out. The comments below didn't really help me. So I am reposting my query.

Below is a snippet of my git status output. The actually output spans couple of pages. And all the files in this output are files/folders I don't want in my repo. These are untracked files so I have never git added them. But when I create a new project, I have to search for the related files/folders in this huge list before adding them, which is making the whole process a bit irritating.

# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   ../../.DS_Store
#   ../../Classes/
#   ../.DS_Store
#   ../Basics/.DS_Store
#   ../adt/.metadata/
#   ../adt/Fundamentals/.classpath
#   ../adt/Fundamentals/.project
#   ../adt/Fundamentals/.settings/
#   ../adt/Fundamentals/bin/
#   .DS_Store
#   .metadata/

Below is my .gitignore file. Can someone please point out my mistake?

*.class
*.pyc                                                                           
colors                                                                          
**/.DS_Store                                                                    

# Mobile Tools for Java (J2ME)                                                  
.mtj.tmp/                                                                       

# Package Files #                                                               
*.jar                                                                           
*.war                                                                           
*.ear                                                                           

#Eclipse files                                                                  
.project                                                                        

# folders                                                                       
.classpath/                                                                     
.settings/                                                                      
.metadata/                                                                      
WEB-INF/lib/                                                                    
META-INF/                                                                       
Servers/ 

# Byte-compiled / optimized / DLL files                                         
__pycache__/                                                                    
*.py[cod]                                                                       

# C extensions                                                                  
*.so                                                                            

# Distribution / packaging                                                      
bin/                                                                            
build/                                                                          
develop-eggs/                                                                   
dist/                                                                           
eggs/                                                                           
lib/                                                                            
lib64/                                                                          
parts/   

解决方案

  1. You shouldn't ignore your .gitignore. I don't think the ignore feature works when you don't have it in your repository. I'm not sure though.
  2. Files that are already tracked won't be ignored, even if you add them to .gitignore. If you want them to be ignored after they've been added to the repository already, you have to remove them with git rm filename first.

这篇关于gitignore只是不起作用。我无法理解它.DS_Store&amp; .gitignore文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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