Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
328 views
in Technique[技术] by (71.8m points)

git - 如何创建.gitignore文件(How to create a .gitignore file)

I need to add some rules to my .gitignore file.

(我需要在我的.gitignore文件中添加一些规则。)

However, I can't find it in my project folder.

(但是,我在项目文件夹中找不到它。)

Isn't it created automatically by Xcode?

(它不是由Xcode自动创建的吗?)

If not, what command allows me to create one?

(如果没有,什么命令允许我创建一个?)

  ask by Luca translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you're using Windows it will not let you create a file without a filename in Windows Explorer.

(如果您使用的是Windows,则不允许您在Windows资源管理器中创建没有文件名的文件。)

It will give you the error " You must type a file name " if you try to rename a text file as .gitignore

(如果您尝试将文本文件重命名为.gitignore ,它将显示错误“ 您必须键入文件名 ”)

在此输入图像描述

To get around this I used the following steps

(为了解决这个问题,我使用了以下步骤)

  1. Create the text file gitignore.txt

    (创建文本文件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

    (按住SHIFT键,右键单击您所在的文件夹,然后在此处选择“ 打开命令窗口”)

  4. Then rename the file in the command line, with ren gitignore.txt .gitignore

    (然后使用ren gitignore.txt .gitignore在命令行中重命名该文件)

Alternatively @HenningCash suggests in the comments

(或者@HenningCash在评论中建议)

You can get around this Windows Explorer error by appending a dot to the filename without extension: .gitignore.

(您可以通过在没有扩展名的文件名后附加一个点来解决此Windows资源管理器错误:.gitignore。)

will be automatically changed to .gitignore

(将自动更改为.gitignore)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...