Git忽略除子目录中的某些文件之外的所有文件

时间:2017-08-11 16:30:08

标签: git gitignore

我正在ASM中开发一些源代码,但我不想保存二进制文件和obj文件,所有文件夹都是新的“项目”,一切正常但是当我在Ubuntu中做了一些更改时没有采取任何更改。例如

/
  |- HelloWorld/
    |- hello.asm
    |- hello.o
    |- hello
  |- SomeProject/
    |- some.asm
    |- some.o
    |- some
  |- CProject/
    |- project.c
    |- project.o
    |- project

我的.gitignore是:

# Ignore all ASM Binaries
*

# Except source codes files in root
!*.c
!*.asm
!*.sh
!*.gitignore
!*.md
!*.txt
# And source code files in subdirectories
!**/*.c
!**/*.asm
!**/*.sh
!**/*.gitignore
!**/*.md
!**/*.txt

也尝试过:

!*/*.txt
!/**/*.txt
!/*/*.txt
!**/*.txt

1 个答案:

答案 0 :(得分:0)

已解决,.gitignore:

# Ignore all files
*

# Ignore all files in subdirectories
#**/**

# Unignore all with extensions
!*.*

# Unignore all files in subdirectories
/*
!/*.asm
!/*.c
!/*.sh
!/*.md
!/*.txt
!/*/
/*/**

!/**/*.asm
!/**/*.c
!/**/*.sh
!/**/*.md
!/**/*.txt

# Except source code files
!.gitignore
!*.readme
!*.c
!*.asm
!*.sh
!*.md
!*.txt