It can be quite daunting to search for something as insignificant as how to create a .gitignore file in the terminal and fail to find a straightforward solution on first-ask. You shouldn’t have to sift through tonnes of articles to get it done. Here is my two-minute solution to the gitignore file debacle!
The image above is pretty self-explanatory but I'll write something down for those that might need more clarity.
- I have a repository that has one file and one folder.
- I create a .gitignore file using the command
>> .gitignore
- I create a README file with the same command but I add
>> README.md echo 'This application shows a calendar in a grid form'
to populate the file with some text. This is what the echo command does.
- I then create a file called ignoreme.html just to illustrate how the .gitignor e file works (I could’ve used the README.md file for that purpose but let’s face it, no one should be ignoring a readme file. That would be utterly reckless!).
- I then add the newly created file to the .gitignore file right in the terminal! with the echo command as earlier seen:
echo 'ignoreme.html' > .gitignore
To ignore a folder in git for windows command, we will tweak the last code with just one extra character.
echo folder_to_ignore/ >> .gitignore
et viola! we don’t see the newly created file or the folder(not in the code) because they’ve been ignored!
Thank you for coming to my ted talk. That’s the gold today!! 😊