Kyle B
Kyle B

Reputation: 31

.gitignore from the beginning. How to add, how to edit. on Rails

I've looked through tons of posts, I've scoured google and stack overflow. Mind you that I am completely new to rails and git and stack, but all i'm looking to do is find out...

Everyone likes to put just type "touch ~/.gitignore" in the terminal and like magic i'm suppose to know where that goes, how it works and what its doing.

then they would say "yep just add database.yml to .gitignore and its good!" Soooo???? how is that now? what does that mean? do I just type add database.yml .gitignore, or add database.yml -.gitignore. -in terminal on mac that does absolutely nothing..

Anyone who understands the .gitignore, or even just understand rails and terminal usage better please try to explain it. Try to explain it like you are talking to someone Who literally has no idea but is very interested in learning!

Upvotes: 1

Views: 2233

Answers (2)

Gab
Gab

Reputation: 1017

touch .gitignore creates a file named .gitignore in the current folder. Then to add things to it, you literally just open the .gitignore file in your favourite editor (gedit, vim, emacs, any IDE, etc) write the name of the file and then hit the return key and add another one. for example,

database.yml
file.fileExtention
anotherFile.FileExtension 
# and I'm a comment because I start with a #
blahblah.extension # everything after the # is a comment

etc...

Upvotes: 0

Lasse Sviland
Lasse Sviland

Reputation: 1517

You place the file called .gitignore in the main directory of your git repository.

To create the file you can use touch .gitignore as you said.

To add entries to the file you can open the file in a text editor, and add each file/folder on a separate line.

Your file may look like this:

/log
/tmp
/config/database.yml

That will ignore the database.yml file from the git repository, as well as the tmp folder and the log folder

Upvotes: 4

Related Questions