如何将 .gitignore 文件添加到 Xcode 项目中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14517440/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add .gitignore file into Xcode project
提问by JOM
When making sure that iPhone project could be installed as an exact copy into a brand new computer via version control (git), I just realized that .gitignorefile was missing. Added under version control, but now would like to add that file also into Xcode projectfor easy viewing and editing.
在确保可以通过版本控制 (git) 将 iPhone 项目作为精确副本安装到全新计算机中时,我才意识到.gitignore文件丢失了。在版本控制下添加,但现在想将该文件也添加到 Xcode 项目中以便于查看和编辑。
When using "Control-click
+ Add Files to myProject...
" popup menu, I can't see any filenames starting with .
(that's a dot). How can I add my .gitignore file into Xcode project?
使用“ Control-click
+ Add Files to myProject...
”弹出菜单时,我看不到任何以.
(这是一个点)开头的文件名。如何将我的 .gitignore 文件添加到 Xcode 项目中?
回答by Kurt Revis
- When the open panel is showing, press
Command-Shift-.
and the hidden files will appear, including.gitignore
. - Select the
.gitignore
file and press the Add button.
- 显示打开的面板时,按
Command-Shift-.
会出现隐藏文件,包括.gitignore
. - 选择
.gitignore
文件并按添加按钮。
This works in any app, not just Xcode. It's an obscure feature of NSOpenPanel
.
这适用于任何应用程序,而不仅仅是 Xcode。这是NSOpenPanel
.
回答by tofortier
This solution didn't work for me in XCode 8.0 and El Capitan.
这个解决方案在 XCode 8.0 和 El Capitan 中对我不起作用。
I opened a terminal and typed:
我打开一个终端并输入:
defaults write com.apple.finder AppleShowAllFiles YES
cd ../PATH_TO_GIT_ROOT
touch .gitignore
Then relaunched Finder and my .gitignore file was visible. Edit per .gitignore documentation
然后重新启动 Finder,我的 .gitignore 文件可见。根据.gitignore 文档编辑