简体   繁体   English

Git会忽略所有文件,除了子目录中的某些文件

[英]Git ignore all files except some files in subdirectories

I'm developing some source codes in ASM but I don't want to save the binaries and obj files, all folders are a new "projects", everything is ok but when I made some changes in Ubuntu not take any changes. 我正在ASM中开发一些源代码,但是我不想保存二进制文件和obj文件,所有文件夹都是一个新的“项目”,一切正常,但是当我在Ubuntu中进行一些更改时,请不要进行任何更改。 Eg. 例如。

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

My .gitignore is: 我的.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

Also tried: 还尝试了:

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

Resolved, .gitignore: 已解决,.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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM