如何创建一个.gitignore文件 [英] How to create a .gitignore file

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

问题描述

我需要在.gitignore文件中添加一些规则.但是,我在项目文件夹中找不到它.它不是由Xcode自动创建的吗?如果没有,什么命令允许我创建一个?

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?

推荐答案

如果您使用的是Windows,则不允许您在Windows资源管理器中创建没有文件名的文件.如果您尝试将文本文件重命名为 .gitignore

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

  1. 创建文本文件gitignore.txt
  2. 在文本编辑器中将其打开并添加规则,然后保存并关闭
  3. 按住SHIFT,右键单击您所在的文件夹,然后选择在此处打开命令窗口
  4. 然后使用ren gitignore.txt .gitignore
  5. 在命令行中重命名文件
  1. Create the text file gitignore.txt
  2. Open it in a text editor and add your rules, then save and close
  3. Hold SHIFT, right click the folder you're in, then select Open command window here
  4. Then rename the file in the command line, with ren gitignore.txt .gitignore

或者 @HenningCash 在评论中建议

您可以通过在以下位置附加一个点来解决Windows资源管理器错误 没有扩展名的文件名:.gitignore.将自动 更改为.gitignore

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屋!

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