关于git:.gitignore与iOS项目无法正常工作

.gitignore is not working properly with iOS project

本问题已经有最佳答案,请猛点这里访问。

这是在发生,我不明白为什么

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
User-MBP:Project user$ git status
On branch playlist
Your branch is ahead of 'origin/playlist' by 1 commit.
  (use"git push" to publish your local commits)
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:   Project.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
    modified:   Project/TPSettings.plist

no changes added to commit (use"git add" and/or"git commit -a")
User-MBP:Project user$ cat .gitignore
SubModules/
.DS_Store
Project.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate
Project.xcodeproj/xcuserdata/user.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
User-MBP:Project user$

文件在.gitignore中,所以不应该告诉我提交文件。


发生这种情况是因为相关文件已经在源代码管理中。您可以使用git rm --cached myFile.txt删除它们。在那之后,他们确实会被忽视。不过,请注意:在您推送您的更改之后拉取repo的其他人将在其工作目录中删除所述文件的本地副本,因此他们可能希望首先进行备份。