我希望我的.gitignore忽略某些文件夹和文件,所以我想出了以下内容:
*.class
# usual java ignores
bin/
.metadata
# Maven
*/target/*
target/*
/target/
*/deploy/*
deploy/*
# src-gen folder is populated by the command of protobuf, these files should not be pushed
src-gen/*
# eclipse generated stuff
dependency-reduced-pom.xml
# we shouldn't have .jar files in our repository,
# apart from these 5 jars which are vital for our build process
*.jar
!/projectName/bundle/**/*.jar
# For Unix editors
# sometimes make file copies ending
# with ~
# To ignore them use:
*~
# For Mac
.DS_Store
._*
# For markdown read me files
.README.md.html
Run Code Online (Sandbox Code Playgroud)
但是,经过一段时间后git status我看不到任何要删除的内容作为输出.请注意,这是一个子模块,如果这很重要的话.我希望这.gitignore可以忽略所有内容而不指定任何文件夹名称,因为我不想要任何硬编码.
这是我的文件夹结构:
+ parentRepo
+ thisRepo
+ .gitignore
+ projectName
+ src-gen
+ target
+ deploy
+ dependency-reduced-pom.xml
+ bundle
+ system
+ 1.jar
+ 2.jar
+ 3.jar
+ 4.jar
+ 5.jar
Run Code Online (Sandbox Code Playgroud)
axi*_*iac 16
"我看不到任何要删除的东西" - 你只是被告知git要忽略一些文件; 现在你希望它删除它们?
.gitignore仅用于尚未跟踪的文件(即将新文件添加到存储库时).如果文件已经在存储库中并且您想要git忽略它,则必须将其从存储库中删除(git rm --cached file)并提交更改.
确保您的.gitignore位于根目录中。在该目录中运行git status并从状态输出复制文件的路径并将其粘贴到.gitignore.
.gitignore只会忽略您尚未添加到存储库中的文件。