如何创建.gitignore文件 [英] How to create .gitignore file
问题描述
我需要为我的 .gitignore
文件添加一些规则,但是,我无法在我的项目文件夹中找到它。它不是由Xcode自动创建的吗?如果没有,那么什么命令允许我创建一个?解析方案
如果你使用Windows,它不会让你创建一个文件在Windows资源管理器中没有文件名。如果您尝试将文本文件重命名为 .gitignore
,则会出现错误您必须输入文件名称。
我使用了以下步骤:
- 创建文本文件gitignore.txt
- 文本编辑器并添加您的规则,然后保存并关闭
- 按住SHIFT,右键单击您所在的文件夹,然后选择在此处打开命令窗口
- 然后在命令行中重命名该文件,使用
ren gitignore.txt .gitignore
或者 @HenningCash 在评论中建议
您可以绕过此Windows资源管理器错误,方法是将
附加到文件名后面:.gitignore。会自动变成
.gitignore
I need to add some rules to my .gitignore
file, however, I can't find it in my project folder. Isn't it created automatically by Xcode? If not, what command allows me to create one?
If you're using Windows it will not let you create a file without a filename in Windows Explorer. It will give you the error "You must type a file name" if you try to rename a text file as .gitignore
To get around this I used the following steps
- Create the text file gitignore.txt
- Open it in a text editor and add your rules, then save and close
- Hold SHIFT, right click the folder you're in, then select Open command window here
- Then rename the file in the command line, with
ren gitignore.txt .gitignore
Alternatively @HenningCash suggests in the comments
You can get around this Windows Explorer error by appending a dot to the filename without extension: .gitignore. will be automatically changed to .gitignore
这篇关于如何创建.gitignore文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!