gitignore使用技巧 a year ago
通常我们在定义.gitignore
时,定义的都是需要ignore的东西, 比如:
# Ignore file
.DS_Store
# Ignore everything in the directory
/a/*
# Ignore directory
node_modules
但是实际开发中还有一些特殊的情况,比如某些代码是用command line tool生成的, 比如ent:
我们所需要的是ent下的schema文件夹及generate.go,所以我们需要反选
这时我们就可以这样配置.gitignore
!ent/schema
!ent/generate.go
我们push code的时候就要把除此之外的其他文件给ignore掉,否则环境变化(eg: golang版本不一致)就会导致各种bug
# Ignore everything in the directory
/a/*
# Don't ignore a.txt and b.txt
!/a/a.txt
!/a/b.txt