Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode gitignore不忽略文件_Xcode_Git_Gitignore - Fatal编程技术网

Xcode gitignore不忽略文件

Xcode gitignore不忽略文件,xcode,git,gitignore,Xcode,Git,Gitignore,无论我在.gitignore中输入什么,我都无法让git忽略下面的UserInterfaceState.xUserState文件: $ 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

无论我在
.gitignore
中输入什么,我都无法让git忽略下面的
UserInterfaceState.xUserState
文件:

$ 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
$git状态
论分行行长
您的分支机构是最新的“原始/主”分支机构。
未为提交而暂存的更改:
(使用“git add…”更新将提交的内容)
(使用“git签出--…”放弃工作目录中的更改)
修改:.gitignore
修改:CalFoo.xcodeproj/project.xcworkspace/xcuserdata/wcochran.xcuserdatad/UserInterfaceState.xcuserstate
我正在使用/编辑上列出的
.gitignore
文件。 我尝试了所有方法来匹配模式,包括确切的路径名:
CalFoo.xcodeproj/project.xcworkspace/xcuserdata/wcochran.xcuserdatad/UserInterfaceState.xcuserstate
,但都没有成功


这个特殊的问题源于工作流,其中使用Xcode创建初始git repo,然后添加
.gitignore
文件。关于忽略git中以前跟踪的文件,可以从中找到一个更一般的答案(我想我在搜索中从未找到过这篇文章,因为它的标题中没有“gitignore”)。

您只能忽略未版本的文件,但git已经知道该文件

如果您希望git跟踪该文件,则无需告诉git忽略它

如果您不希望git跟踪该文件,请使用
git rm
,您的忽略规则将开始工作

注意:
git-rm
将删除该文件。
使用
git-rm--cached
从回购中删除,而不是从磁盘中删除。

我也遇到了同样的问题

首先提交所有未完成的代码更改,然后运行以下命令:

git rm -r --cached .
这将从索引(暂存区域)中删除任何更改的文件,然后运行:

git add .
承诺:

git commit -m ".gitignore working now"

要撤消git rm--缓存的文件名,请使用git add filename。

这里完美地解释了忽略GitHub上文件的一种简单方法

在推送到GitHub之前,您的项目文件夹应该是空的。

1) 打开终端并写入cd

然后将项目文件夹拖到终端上。之后,它将如下所示:

docmacbook$ cd /Users/docmacbook/Downloads/MyProjectFolder
MyAppName.xcodeproj/xcuserdata
MyAppName.xcworkspace/xcuserdata
Pods
report.xml
2) 打开.gitignore文件并添加要忽略的文件。例如,my.gitignore文件如下所示:

docmacbook$ cd /Users/docmacbook/Downloads/MyProjectFolder
MyAppName.xcodeproj/xcuserdata
MyAppName.xcworkspace/xcuserdata
Pods
report.xml
3) 提交推送到GitHub

在此之后,请移动您的项目或在.gitignore文件所在的文件夹中创建一个新项目,现在您希望忽略的文件将不会推送到GitHub


注意:这些步骤也适用于现有的项目,我认为没有经过测试。

对于我来说,我必须将我的列表添加到xcode源代码管理忽略的文件中。 在忽略的文件中设置->源代码管理->git->+

为了更好地测量,请确保重置,以便新的git规则能够工作

git rm -r --cached .
git add .

注意,
git rm
将删除该文件。使用
git rm--cached
从repo中删除,而不是从磁盘中删除。感谢@michas和Darkhogg--它现在没有被get跟踪,而是从repo中删除。这个答案与我以前的想法一致:但是今天,我有一个文件在.gitignore中,它不受控制,它仍然显示在“git status”中作为未跟踪的文件(其文件名为“build”)。没有多少“git rm build”或触摸.gitignore有帮助。有什么想法吗?同样的问题@Stabledog@Stabledog@AllenLinatoc存在多个可能的忽略文件,这些文件可能包含排除规则。尝试
git check ignore
,可能会问一个新问题以了解发生了什么。可能重复的@Unicornist不是重复的-我希望删除一个特定的文件并忽略所有地方,而另一个问题希望不全局跟踪某些文件。