0

I am reading a book by Ethan Brown called Learning JavaScript. On Ch2 the author will start describing and teaching how to use some tools that will be interesting to learn throughout the course. One of them is git.

There is this part where he tells me to add .gitignore and add a few contents to it.

But I haven't found a way that didn't throw me errors. The passage goes as follows:

First, from your project root, initialize a repository:

$ git init

This will create a project repository for you (there’s now a hidden directory called .git in your project root).

Inevitably, there will be some files you never want tracked in version control: build artifacts, temporary files, and the like. These files can be explicitly excluded in a file called .gitignore. Go ahead and create a .gitignore file now with the following contents:

# npm debugging logs
npm-debug.log*

# project dependencies
node_modules

# OSX folder attributes
.DS_Store

# temporary files
*.tmp
*~

I was able to create the git init. That was easy. But from then on things got a little complicated.

I tried adding the .gitignore file from this resource provided by sully6768 -> How to create .gitignore file

And it worked. But I wasn't able to commit the content to .gitignore.

So pretty much my question is...

How do I make the part bellow work using Linux Terminal.

Go ahead and create a .gitignore file now with the following contents:

# npm debugging logs
npm-debug.log*

# project dependencies
node_modules

# OSX folder attributes
.DS_Store

# temporary files
*.tmp
*~

I don't know how to do that.

Thank you in advance.

Other sources investigated:

  1. Adding files to gitignore
  2. Add .gitignore to gitignore
  3. add #*# glob to .gitignore?
  4. How to create .gitignore file

Citation from: Learning JavaScript by Ethan Brown Copyright © 2015 O’Reilly Media. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc. , 1005 Gravenstein Highway North, Sebastopol, CA 95472.

Vadim Kotov
  • 7,103
  • 8
  • 44
  • 57

2 Answers2

0

.gitignore is just like other normal file. Open it by any text editor you like (notepad, sublime text, atom, vs code,...) . Then copy the text the book told you to copy and then paste into that .gitignore file.

Minh Tri Le
  • 320
  • 2
  • 11
  • I have edited to using Linux terminal. Because the author implies that I'm using a terminal/console from an OS in the book. But I'll try that and see if it works. Thank you. –  Dec 29 '18 at 07:59
0

I saw that I could answer my question provided I have come to a conclusion on what is the best approach provided the question I made it. And in order not to leave another question unanswered. So here I go:

The answer Mr. Minh provided isn't actually wrong but it doesn't deliver what the OP (me) want which is to create a .gitignore file and add those features in the file using the terminal. In order to do this in Debian9 you should:

  1. Open your terminal
  2. cd into the desired folder
  3. use the cat > to create the .gitignore file.

So this is how it is going to work.

Once you have navigated into your desired folder you will use cat > .gitignore which will allow you to write whatever you want in it. Like this...

How to use cat > to add .gitignore

And when you finish you just need to press ctrl c (on Debian9) and the file will be created and saved with the info desired.

For more information on how to use the cat > to create file please follow the link below.

How to quickly Create a Text File using the command Line in Linux by Walter Glen