How to create .gitignore file

2019-01-03 11:23发布

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?

30条回答
虎瘦雄心在
2楼-- · 2019-01-03 12:01

I use notepad++. New File > SaveAs > .gitignore (Save as type -> All types(.))

查看更多
时光不老,我们不散
3楼-- · 2019-01-03 12:02

I have another simple idea
Let's use the echo command in cmd ,

echo ./idea > .gitignore

this will create the .gitignore file having text content "./idea"
you may now manually change data from the file using text editor.

or simply

console :

echo .gitignore notepad.exe

to instantly edit gitignore.

If you dont know which files are should be gitignored for your IDE or Operating System just goto www.gitignore.io

gitignore.io - here it wll generate the gitignore commands or text for you just say your api or os thats it!. Just copy and paste into your file. simple!

查看更多
乱世女痞
4楼-- · 2019-01-03 12:02

Here's my personal favorite, http://help.github.com/ignore-files/

Also just in case you wanted to ignore xcode files, refer to this answer https://stackoverflow.com/a/49488/126235

查看更多
ら.Afraid
5楼-- · 2019-01-03 12:03

Here a nice tip under Windows:

  • Right click in Windows Explorer, New > Text Document
  • Name it .gitignore. (with a trailing dot - that is the tip)
  • You end up with a .gitignore file :)

Tested under Windows 7 and 8.

This tip assumes that your Windows Explorer displays the file extensions.

Windows Explorer .gitignore

查看更多
戒情不戒烟
6楼-- · 2019-01-03 12:03

if you use Sublime as your IDE you can create a new file and save it as .gitignore. Simply using ctrl N for the new file, and ctrl S to save as ".gitignore".

查看更多
爷的心禁止访问
7楼-- · 2019-01-03 12:04
1. Open git terminal
2. go to git repository of the project
3. create a .gitignore file by **touch .gitignore** command
4. **git add .gitignore** command to add ignore file
5. set ignore rules in the ignore file
6. run the command **cat .gitignore**

By running the command in step 3 you will get the .gitignore file in the project directory. Thanks.

查看更多
登录 后发表回答