最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I select git ignore Node.js AFTER I've already created a repository? - Stack Overflow

programmeradmin5浏览0评论

I have made a new repository. It's a JavaScript/HTML/CSS project.

When I created the directory on my GitHub profile, I forgot to select git ignore Node.js from the git ignore dropdown menu.

Is there a way for me to ignore Node.js after I've already created the repository?

Thank you for you help.

I have made a new repository. It's a JavaScript/HTML/CSS project.

When I created the directory on my GitHub.com profile, I forgot to select git ignore Node.js from the git ignore dropdown menu.

Is there a way for me to ignore Node.js after I've already created the repository?

Thank you for you help.

Share Improve this question asked Oct 4, 2018 at 13:38 Liam HayesLiam Hayes 1412 gold badges2 silver badges10 bronze badges 1
  • Change the .gitignore to add the Node.js and commit that file – Gangadhar Jannu Commented Oct 4, 2018 at 13:49
Add a comment  | 

3 Answers 3

Reset to default 19

If .gitignore not already created just add a new file .gitignore with below content in your project directory. If the file already created you can add below content in existing file.

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# dotenv environment variables file
.env

You can find more suitable ignores here Node.gitignore. After creating a new file run the following commands for update on upstream.

git rm -r --cached . 
git add .
git commit -m 'Removed all files that are in the .gitignore' 
git push origin master

This will help you to solve your problem.

You can always create a new .gitignore file manually if it is not already created. If a file is existing, you can edit .gitignore file and add it into your repository.

  1. Create manually .gitignore file in root of repository.

    https://github.com/github/gitignore/blob/main/Node.gitignore

  2. Copy the contents of the Node.gitignore file from the GitHub page. Paste the copied contents into your newly created ".gitignore" file.

  3. Save the ".gitignore" file. By following these steps, you will have manually created a .gitignore file and added the recommended rules specific to Node.js projects from the provided link.

You may also add custom rules as per standard.

This file will help exclude unnecessary files and directories from version control, improving the cleanliness and organisation of your repository.

发布评论

评论列表(0)

  1. 暂无评论