gitignore不会忽略文件 [英] gitignore not ignoring file

查看:100
本文介绍了gitignore不会忽略文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不管我把什么放在 .gitignore 我都可以不用让git忽略 UserInterfaceState.xcuserstate code $>

  $ git status 
分支主
您的分支已启动与'origin / master'最新。

没有为commit提交更改:
(使用git add< file> ...更新将提交的内容)
(使用git checkout - < ; file> ...放弃工作目录中的更改)

修改:.gitignore
修改:CalFoo.xcodeproj / project.xcworkspace / xcuserdata / wcochran.xcuserdatad / UserInterfaceState.xcuserstate

我正在使用/编辑 .gitignore 文件列在此文章上。
我尝试了一切,以匹配包括确切路径名称的模式: CalFoo.xcodeproj / project.xcworkspace / xcuserdata / wcochran.xcuserdatad / UserInterfaceState.xcuserstate 无济于事。

这个特殊的问题来自工作流,其中Xcode用于创建初始git仓库和 .gitignore 文件之后添加此处。忽略git中先前跟踪的文件的更一般的答案可以从这个问题(我猜我从来没有在我的搜索中找到这篇文章,因为它没有标题中的gitignore)。 解决方案

如果你想让git跟踪那个文件,不需要告诉git忽略它。



如果你不想让git跟踪那个文件,使用 git rm 和您的忽略规则将开始工作。



警告: git rm 会删除文件。 / strong>使用 git rm --cached 从回购库中移除,而不是从磁盘中移除。


No matter what I put in .gitignore I can not get git to ignore the UserInterfaceState.xcuserstate file below:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   .gitignore
    modified:  CalFoo.xcodeproj/project.xcworkspace/xcuserdata/wcochran.xcuserdatad/UserInterfaceState.xcuserstate

I am using/editing the .gitignore file listed on this post. I tried everything to match the pattern including the exact pathname: CalFoo.xcodeproj/project.xcworkspace/xcuserdata/wcochran.xcuserdatad/UserInterfaceState.xcuserstate to no avail.

This particular problem arises from the workflow where Xcode is used to create the initial git repo and the .gitignore file from here is added afterwards. A more general answer to ignoring previously tracked files in git can be found from this question (I guess I never found this post in my search since it didn't have "gitignore" in the title).

解决方案

You can only ignore unversioned files but that file is already known to git.

If you want git to track that file, there is no need to tell git to ignore it.

If you don't want git to track that file use git rm and your ignore rule will start working.

Caution: git rm will remove the file. Use git rm --cached to remove from the repo but not from the disk.

这篇关于gitignore不会忽略文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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