LinMinquan's Blog

Experience technology to change life

Sourcetree无法增加文件

在使用Sourcetree时,准备提交代码,发现Unstaged files里有个文件夹里的文件没有在Sourcetree里显示出来。

1、第一反应是查看该Git Pepository的.gitignore文件,发现我没有ignore那个文件夹。

2、我打开Sourcetree的Terminal,想手动添加该文件夹下的文件。

git add xx/yy.h ,却提示:

The following paths are ignored by one of your .gitignore files

那到底是哪个.gitignore 文件忽略了我的这个文件夹。Mac OS默认是无法搜索隐藏文件,在Spotlight Search里还搜不到其它的.gitignore文件。

其实可以加 -f 来强制添加这些文件,但我多搜了几下,找到了原因。

3、git check-ignore -v xx/yy.h 该命令可以告诉你哪个规则使得你无法添加该文件了。

原因在/Users/xxxxxx/.gitignore_global 里有规则忽略掉了那个文件夹。不知道啥时候Sourcetree创建了这个全局的gitignore文件。

参考链接:

忽略特殊文件

http://stackoverflow.com/questions/9436405/git-is-ignoring-files-that-arent-in-gitignore


Share