Git ignore 不忽略指定的 folders/files
Git ignore doesn't ignore the specified folders/files
我想让我的 .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
但是,在 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
确保您的 .gitignore
在根目录中。在该目录 运行 git status
中,从状态输出复制文件路径并将其粘贴到 .gitignore
.
.gitignore
只会忽略您尚未添加到存储库的文件。
"I cannot see anything to be deleted" -- 你刚刚告诉 git
忽略一些文件;现在你希望它删除它们?
.gitignore
仅用于尚未跟踪的文件(即当新文件添加到存储库时)。如果该文件已经在存储库中并且您希望 git
忽略它,那么您必须将其从存储库中删除 (git rm --cached file
) 并提交更改。
我想让我的 .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
但是,在 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
确保您的 .gitignore
在根目录中。在该目录 运行 git status
中,从状态输出复制文件路径并将其粘贴到 .gitignore
.
.gitignore
只会忽略您尚未添加到存储库的文件。
"I cannot see anything to be deleted" -- 你刚刚告诉 git
忽略一些文件;现在你希望它删除它们?
.gitignore
仅用于尚未跟踪的文件(即当新文件添加到存储库时)。如果该文件已经在存储库中并且您希望 git
忽略它,那么您必须将其从存储库中删除 (git rm --cached file
) 并提交更改。