How to "Create an empty file in your favorite editor and save it as ".gitignore" in your project's root folder."?


#1

This is from Tower’s Learn Verson Control with Git.

I am in my some-sample-project folder. It says to create an empty file and save it as .gitignore in the project’s root folder, and then make sure it contains at least .DS_Store.

So while in some-sample-project, I typed ‘touch .gitignore’, and it was created. But how do I put .DS_Store inside .gitignore? .gitignore is not a folder, it’s a file.

This isn’t explained well for beginners at all. Please help.


#2

Here’s two(2) ways I can think of

Open .gitignore in a text editor
add .DS_Store on the first line and save it

even easier
echo ".DS_Store" >> .gitignore
while in that same directory as the .gitignore file
the “>>” symbol tells the shell to append the string to the named file
Even better still, create your `.gitignore’ by typing

echo ".DS_store" > .gitignore

that will create and fill your .gitignore file in one command entry instead of creating it and then editing it. You know, typical lazy programmer :grinning:
Why so many keystrokes?


#3

Thanks, @PhroggDev. Again, they assume I know how to “Make sure it contains .DS_Store”, without giving me any clue as to how to accomplish that.

I will try opening gitignore in the vscode and enter what I want to ignore.

Tnanks for the tips.