环境:windows + git bash。
一、问题来源
由于之前用Goland建立Golang工程时,生成了.idea文件,不小心上传至Github:
所以尝试用.gitignore进行忽略不上传。
二、步骤
1,在本地新建一个.gitignore文件
2,在vi环境下选择插入模式,写入/.idea,并保存退出,我们用cat命令进行查看刚写入的内容
3,删除本地的.idea文件夹,并重新add - commit - push上传
三、小结
.gitignore文件是用来忽视提交到Github上的文件和文件夹的,除了忽略掉文件夹,还有其他用法:
- ##注释##:注释
- /文件夹/ :过滤文件夹
- *.xml :过滤某类型的文件
- /mtk/do.c:指定过滤具体文件
- !开头表示不过滤
- *.[oa] 支持通配符:过滤repo中所有以.o或者.a为扩展名的文件