git add all except ignoring files in .gitignore file

一笑奈何 提交于 2019-11-29 19:04:04

I think you mean git add . which will add all of the files to the repo that AREN'T specified in the .gitignore - you can see these changes by typing git status

The . in bash usually means this directory and all other directories recursively, so if you do this from the bottom level of your repo, you should add all of the files.

My usual git flow is to create the .gitignore file and add the project files to the repo. I'll test the .gitignore file by typing git status after importing the files - if I see the files that I've added (for example only .php or .html, NOT .mp3 or .mov), then you can git add . to add all, and git commit -m "initial commit" to commit them and you should be set.

git add .

This will add all paths and ignore matches from .gitignore

wadesworld

Try git add . (which means "add all files in the current directory and below")

Another option is to use the Git repo's exclude file. This file works similar to a .gitignore file but isn't committed to the repo.

From the Github docs:

You can use this technique for locally-generated files that you don't expect other users to generate, such as files created by your editor.

Use your favorite text editor to open the file called .git/info/exclude within the root of your Git repository. Any rule you add here will not be checked in, and will only ignore files for your local repository.

  1. In Terminal, navigate to the location of your Git repository
  2. Using your favorite text editor, open the file .git/info/exclude
  3. Add rules to the exclude file as you would the .gitignore file
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!